docs(Validator): Expand documentation with complete rules reference
This commit is contained in:
@@ -7,27 +7,49 @@ use Exception;
|
|||||||
/**
|
/**
|
||||||
* Validator - DuckBrain
|
* Validator - DuckBrain
|
||||||
*
|
*
|
||||||
* Complementary library to the Request library.
|
* Complementary library to the Request library. Simplifies value verification.
|
||||||
* Simplifies value verification.
|
* It can validate both individual rules and batches (see validateList()).
|
||||||
*
|
*
|
||||||
* It has the ability to verify both individual rules and in batches.
|
* Model: a batch stops at the FIRST failing rule and records it in
|
||||||
|
* $lastFailed as "field.rule[:args]"; there is no error bag. Use message() to
|
||||||
|
* turn a $lastFailed into a human message with the :attribute placeholder
|
||||||
|
* (Request::validate() already does this for its single HTTP 422 error).
|
||||||
*
|
*
|
||||||
* |----------+--------------------------------------------------------|
|
* Rules are a pipe-separated list per field, e.g. "required|email", with
|
||||||
* | Rule | Description |
|
* optional arguments after a colon. The file rules (file/image/mimes) mark a
|
||||||
* |----------+--------------------------------------------------------|
|
* field as a "file field"; in that case min/max/between/size measure kilobytes
|
||||||
* | not | Negates the next rule. Ex: not:float |
|
* per upload and required/nullable act on uploads. Files are checked against
|
||||||
* | exists | Is required; must be defined and can be empty |
|
* their real, sniffed MIME type - never the file name or the client type.
|
||||||
* | required | Is required; must be defined and not empty |
|
|
||||||
* | number | Is numeric |
|
|
||||||
* | int | Is an integer |
|
|
||||||
* | float | Is a float |
|
|
||||||
* | bool | Is a boolean |
|
|
||||||
* | email | Is an email |
|
|
||||||
* | enum | Is in a list of values. Ex: enum:admin,user,guest |
|
|
||||||
* | url | Is a valid URL |
|
|
||||||
* |----------+--------------------------------------------------------|
|
|
||||||
*
|
*
|
||||||
* Rule lists are separated by |, e.g., required|email
|
* |---------------+---------------+---------------------------------------------|
|
||||||
|
* | Rule | Arguments | Description |
|
||||||
|
* |---------------+---------------+---------------------------------------------|
|
||||||
|
* | not | :rule | Negates the following rule. Ex: not:float |
|
||||||
|
* | exists | | Must be defined (may be empty) |
|
||||||
|
* | required | | Must be defined and not empty |
|
||||||
|
* | nullable | | Allows empty; skips the field's other rules |
|
||||||
|
* | string | | Must be a string |
|
||||||
|
* | array | | Must be an array |
|
||||||
|
* | number | | Must be numeric |
|
||||||
|
* | int | | Must be an integer |
|
||||||
|
* | float | | Must be a float |
|
||||||
|
* | bool | | Must be a boolean |
|
||||||
|
* | email | | Must be a valid email address |
|
||||||
|
* | url | | Must be a valid URL |
|
||||||
|
* | date | | Must be a parseable date |
|
||||||
|
* | regex | :pattern | Must match a PCRE pattern (with delimiters) |
|
||||||
|
* | enum | :a,b,c | Must be one of the listed values |
|
||||||
|
* | min | :n | Length/number/count min (files: KB) |
|
||||||
|
* | max | :n | Length/number/count max (files: KB) |
|
||||||
|
* | between | :min,:max | Value within range (files: KB per upload) |
|
||||||
|
* | size | :n | Exact length/number/count (files: KB) |
|
||||||
|
* | confirmed | | Must match the '<field>_confirmation' field |
|
||||||
|
* | required_with | :fields | Required when a listed field is present |
|
||||||
|
* | required_if | :field,:value | Required when a field equals a value |
|
||||||
|
* | file | | Value must be an uploaded file ($_FILES) |
|
||||||
|
* | image | | Uploaded file must be an image (real MIME) |
|
||||||
|
* | mimes | :ext,ext | Uploaded file's real MIME must match |
|
||||||
|
* |---------------+---------------+---------------------------------------------|
|
||||||
*
|
*
|
||||||
* @author KJ
|
* @author KJ
|
||||||
* @website https://kj2.me
|
* @website https://kj2.me
|
||||||
|
|||||||
Reference in New Issue
Block a user