StringRule
class StringRule implements Stringable (View source)
Traits
Properties
| protected | $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
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
StringRule
alpha(bool $ascii = false)
The field under validation must be entirely alphabetic characters.
StringRule
alphaDash(bool $ascii = false)
The field under validation must be entirely alpha-numeric characters, dashes, and underscores.
StringRule
alphaNumeric(bool $ascii = false)
The field under validation must be entirely alpha-numeric characters.
StringRule
ascii()
The field under validation must be entirely ASCII characters.
StringRule
between(int $min, int $max)
The field under validation must have a length between the given min and max (inclusive).
StringRule
doesntEndWith(string ...$values)
The field under validation must not end with any of the given values.
StringRule
doesntStartWith(string ...$values)
The field under validation must not start with any of the given values.
StringRule
endsWith(string ...$values)
The field under validation must end with one of the given values.
StringRule
exactly(int $value)
The field under validation must have an exact length.
StringRule
lowercase()
The field under validation must be entirely lowercase.
StringRule
max(int $value)
The field under validation must not exceed the given length.
StringRule
min(int $value)
The field under validation must have a minimum length.
StringRule
startsWith(string ...$values)
The field under validation must start with one of the given values.
StringRule
uppercase()
The field under validation must be entirely uppercase.
string
__toString()
Convert the rule to a validation string.
protected StringRule
addRule(array|string $rules)
Add custom rules to the validation rules array.