Skip to content

Commit 9258a94

Browse files
apihtaylorotwell
andauthored
[12.x] Add error message for doesnt_contain rule (#56644)
* Add error message for `doesnt_contain` rule * Update ReplacesAttributes.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 41e7719 commit 9258a94

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Illuminate/Translation/lang/en/validation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
'digits_between' => 'The :attribute field must be between :min and :max digits.',
4949
'dimensions' => 'The :attribute field has invalid image dimensions.',
5050
'distinct' => 'The :attribute field has a duplicate value.',
51+
'doesnt_contain' => 'The :attribute field must not contain any of the following: :values.',
5152
'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.',
5253
'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.',
5354
'email' => 'The :attribute field must be a valid email address.',

src/Illuminate/Validation/Concerns/ReplacesAttributes.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,4 +932,22 @@ protected function replaceDoesntStartWith($message, $attribute, $rule, $paramete
932932

933933
return str_replace(':values', implode(', ', $parameters), $message);
934934
}
935+
936+
/**
937+
* Replace all place-holders for the doesnt_contain rule.
938+
*
939+
* @param string $message
940+
* @param string $attribute
941+
* @param string $rule
942+
* @param array<int,string> $parameters
943+
* @return string
944+
*/
945+
protected function replaceDoesntContain($message, $attribute, $rule, $parameters)
946+
{
947+
foreach ($parameters as &$parameter) {
948+
$parameter = $this->getDisplayableValue($attribute, $parameter);
949+
}
950+
951+
return str_replace(':values', implode(', ', $parameters), $message);
952+
}
935953
}

0 commit comments

Comments
 (0)