digitalrevolution/symfony-validation-shorthand
| Index |
|---|
| Shorthands |
| Array data validation |
| Traversable data validation |
| Examples |
| General | Type | Range | Pattern | Date |
|---|---|---|---|---|
| filled | array | between | alpha | date |
| nullable | boolean | max | alpha_dash | datetime |
| required | float | min | alpha_num | date_format |
| integer | ||||
| string | in | |||
| regex | ||||
| url |
The field under validation must be entirely alphabetic characters. Shorthand for pattern: [a-zA-Z]
The field under validation may have alpha-numeric characters, as well as dashes and underscores. Shorthand for pattern: [a-zA-Z0-9_-]
The field under validation must be entirely alpha-numeric characters. Shorthand for pattern: [a-zA-Z0-9]
The field under validation must be a PHP array.
Arguments: <digit>,<digit>
The constraint has different implementations based on the value type.
<digit> arguments accepts now DateTime
allowed formats. The value must be between than the supplied <digit> arguments.
More information in the Symfony Validation documentation.Example:
between:2,6integer|between:2,62010-01-01 and 2011-01-01: date|between:2010-01-01,2011-01-01The value must be bool or castable to bool.
true values: 1, '1', 'on', truefalse values: 0, '0', 'off', falseNote: can also be written as bool
The value must be a valid date of format Y-m-d
The value must be a valid date+time of format Y-m-d H:i:s
Argument: <pattern>
The value must match the given date pattern. See DateTime::createFromFormat() for formatting options.
The value must be a valid email.
The value must be filled and not be null (except if nullable is also set). If the value is an empty string, this validation rule fails.
The value must be a float or castable to float.
-1, 1, -1.1, 1.1, '1.1', '-1.1', '.1', '1.', '1', '-1'Arguments: string,string,...
The field under validation must be included in the given list of values.
Example:
required|in:foo,bar
The value must be an integer or castable to int.
1, -1, '1', '-1'Note: can also be written as int
Argument: <digit>
The constraint has different implementations based on the value type.
<digit> argument accepts now DateTime
allowed formats and the value must be less or equal than the supplied argument.
More information in the Symfony Validation documentation.Example:
max:6integer|max:6date|max:+10 daysArgument: <value>
The constraint has different implementations based on the value type.
<digit> argument accepts now DateTime
allowed formats and the value must be greater or equal than the supplied <digit> argument.
More information in the Symfony Validation documentation.Example:
min:6integer|min:6date|min:nowThe value can be null.
Argument: <pattern>
The value must match the supplied regex. The full string will be passed to the preg_match function.
Example:
regex:/^ab.*$/By default in a data set a key/value-pair can be left out. Add required to make the key/value-pair mandatory.
Example:
[
'a' => 'required|string',
'b' => 'integer'
]
Passes:
['a' => 'a'];
Fails:
['b' => '1'];
The value must be a string.
The value must be a valid url.
How can I help you explore Laravel packages today?