StringRule
class StringRule implements Stringable
Traits
Properties
| protected array | $constraints | The constraints for the string rule. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
The field under validation must be entirely alphabetic characters.
The field under validation must be entirely alpha-numeric characters, dashes, and underscores.
The field under validation must be entirely alpha-numeric characters.
The field under validation must be entirely ASCII characters.
The field under validation must have a length between the given min and max (inclusive).
The field under validation must not end with any of the given values.
The field under validation must not start with any of the given values.
The field under validation must end with one of the given values.
The field under validation must have an exact length.
The field under validation must be entirely lowercase.
The field under validation must not exceed the given length.
The field under validation must have a minimum length.
The field under validation must start with one of the given values.
The field under validation must be entirely uppercase.
Convert the rule to a validation string.
Add custom rules to the validation rules array.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 23
StringRule
alpha(bool $ascii = false)
The field under validation must be entirely alphabetic characters.
at line 31
StringRule
alphaDash(bool $ascii = false)
The field under validation must be entirely alpha-numeric characters, dashes, and underscores.
at line 39
StringRule
alphaNumeric(bool $ascii = false)
The field under validation must be entirely alpha-numeric characters.
at line 47
StringRule
ascii()
The field under validation must be entirely ASCII characters.
at line 55
StringRule
between(int $min, int $max)
The field under validation must have a length between the given min and max (inclusive).
at line 63
StringRule
doesntEndWith(string ...$values)
The field under validation must not end with any of the given values.
at line 71
StringRule
doesntStartWith(string ...$values)
The field under validation must not start with any of the given values.
at line 79
StringRule
endsWith(string ...$values)
The field under validation must end with one of the given values.
at line 87
StringRule
exactly(int $value)
The field under validation must have an exact length.
at line 95
StringRule
lowercase()
The field under validation must be entirely lowercase.
at line 103
StringRule
max(int $value)
The field under validation must not exceed the given length.
at line 111
StringRule
min(int $value)
The field under validation must have a minimum length.
at line 119
StringRule
startsWith(string ...$values)
The field under validation must start with one of the given values.
at line 127
StringRule
uppercase()
The field under validation must be entirely uppercase.
at line 135
string
__toString()
Convert the rule to a validation string.
at line 143
protected StringRule
addRule(array|string $rules)
Add custom rules to the validation rules array.