Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions services/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,119 +172,119 @@ Below is a list of all available validation rules and their function:

- [Accepted](#accepted)
- [Active URL](#active_url)
- [After (Date)](#after_date_)
- [After (Date)](#after_date)
- [Alpha](#alpha)
- [Alpha Dash](#alpha_dash)
- [Alpha Numeric](#alpha_num)
- [Array](#array)
- [Before (Date)](#before_date_)
- [Between](#between_min__max_)
- [Before (Date)](#before_date)
- [Between](#between_min_max)
- [Boolean](#boolean)
- [Confirmed](#confirmed)
- [Date](#date)
- [Date Format](#date_format_format_)
- [Different](#different_field_)
- [Digits](#digits_value_)
- [Digits Between](#digits_between_min__max_)
- [Date Format](#date_format_format)
- [Different](#different_field)
- [Digits](#digits_value)
- [Digits Between](#digits_between_min_max)
- [E-Mail](#email)
- [Exists (Database)](#exists_table__column_)
- [Exists (Database)](#exists_table_column)
- [Image (File)](#image)
- [In](#in_foo__bar_)
- [In](#in_foo_bar)
- [Integer](#integer)
- [IP Address](#ip)
- [Max](#max_value_)
- [MIME Types](#mimes_foo__bar_)
- [Min](#min_value_)
- [Not In](#not_in_foo__bar_)
- [Max](#max_value)
- [MIME Types](#mimes_foo_bar)
- [Min](#min_value)
- [Not In](#not_in_foo_bar)
- [Nullable](#nullable)
- [Numeric](#numeric)
- [Regular Expression](#regex_pattern_)
- [Regular Expression](#regex_pattern)
- [Required](#required)
- [Required If](#required_if_field__value_)
- [Required With](#required_with_foo__bar_)
- [Required With All](#required_with_all_foo__bar_)
- [Required Without](#required_without_foo__bar_)
- [Required Without All](#required_without_foo__bar_)
- [Same](#same_field_)
- [Size](#size_value_)
- [String](#string_value_)
- [Required If](#required_if_field_value)
- [Required With](#required_with_foo_bar)
- [Required With All](#required_with_all_foo_bar)
- [Required Without](#required_without_foo_bar)
- [Required Without All](#required_without_foo_bar)
- [Same](#same_field)
- [Size](#size_value)
- [String](#string_value)
- [Timezone](#timezone)
- [Unique (Database)](#unique_table__column__except__idcolumn_)
- [Unique (Database)](#unique_table_column_except_idcolumn)
- [URL](#url)

</div>

### Validation rules list

#### `accepted`
#### `accepted` {#accepted}

The field under validation must be _yes_, _on_, or _1_. This is useful for validating "Terms of Service" acceptance.

#### `active_url`
#### `active_url` {#active_url}

The field under validation must be a valid URL according to the `checkdnsrr` PHP function.

#### `after:_date_`
#### `after:_date_` {#after_date}

The field under validation must be a value after a given date. The dates will be passed into the PHP `strtotime` function.

#### `alpha`
#### `alpha` {#alpha}

The field under validation must be entirely alphabetic characters.

#### `alpha_dash`
#### `alpha_dash` {#alpha_dash}

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

#### `alpha_num`
#### `alpha_num` {#alpha_num}

The field under validation must be entirely alpha-numeric characters.

#### `array`
#### `array` {#array}

The field under validation must be of type array.

#### `before:_date_`
#### `before:_date_` {#before_date}

The field under validation must be a value preceding the given date. The dates will be passed into the PHP `strtotime` function.

#### `between:_min_,_max_`
#### `between:_min_,_max_` {#between_min_max}

The field under validation must have a size between the given _min_ and _max_. Strings, numerics, and files are evaluated in the same fashion as the `size` rule.

#### `boolean`
#### `boolean` {#boolean}

The field under validation must be able to be cast as a boolean. Accepted input are `true`, `false`, `1`, `0`, `"1"` and `"0"`.

#### `confirmed`
#### `confirmed` {#confirmed}

The field under validation must have a matching field of `foo_confirmation`. For example, if the field under validation is `password`, a matching `password_confirmation` field must be present in the input.

#### `date`
#### `date` {#date}

The field under validation must be a valid date according to the `strtotime` PHP function.

#### `date_format:_format_`
#### `date_format:_format_` {#date_format_format}

The field under validation must match the _format_ defined according to the `date_parse_from_format` PHP function.

#### `different:_field_`
#### `different:_field_` {#different_field}

The given _field_ must be different than the field under validation.

#### `digits:_value_`
#### `digits:_value_` {#digits_value}

The field under validation must be _numeric_ and must have an exact length of _value_.

#### `digits_between:_min_,_max_`
#### `digits_between:_min_,_max_` {#digits_between_min_max}

The field under validation must have a length between the given _min_ and _max_.

#### `email`
#### `email` {#email}

The field under validation must be formatted as an e-mail address.

#### `exists:_table_,_column_`
#### `exists:_table_,_column_` {#exists_table_column}

The field under validation must exist on a given database table.

Expand Down Expand Up @@ -312,27 +312,27 @@ Passing `NULL` as a "where" clause value will add a check for a `NULL` database
'email' => 'exists:staff,email,deleted_at,NULL'
```

#### `image`
#### `image` {#image}

The file under validation must be an image (jpeg, png, bmp, or gif)

#### `in:_foo_,_bar_,...`
#### `in:_foo_,_bar_,...` {#in_foo_bar}

The field under validation must be included in the given list of values.

#### `integer`
#### `integer` {#integer}

The field under validation must have an integer value.

#### `ip`
#### `ip` {#ip}

The field under validation must be formatted as an IP address.

#### `max:_value_`
#### `max:_value_` {#max_value}

The field under validation must be less than or equal to a maximum _value_. Strings, numerics, and files are evaluated in the same fashion as the [`size`](#size_value_) rule.

#### `mimes:_foo_,_bar_,...`
#### `mimes:_foo_,_bar_,...` {#mimes_foo_bar}

The file under validation must have a MIME type corresponding to one of the listed extensions.

Expand All @@ -342,73 +342,73 @@ The file under validation must have a MIME type corresponding to one of the list
'photo' => 'mimes:jpeg,bmp,png'
```

#### `min:_value_`
#### `min:_value_` {#min_value}

The field under validation must have a minimum _value_. Strings, numerics, and files are evaluated in the same fashion as the [`size`](#size_value_) rule.

#### `not_in:_foo_,_bar_,...`
#### `not_in:_foo_,_bar_,...` {#not_in_foo_bar}

The field under validation must not be included in the given list of values.

#### `nullable`
#### `nullable` {#nullable}

The field under validation may be `null`. This is particularly useful when validating primitive such as strings and integers that can contain `null` values.

#### `numeric`
#### `numeric` {#numeric}

The field under validation must have a numeric value.

#### `regex:_pattern_`
#### `regex:_pattern_` {#regex_pattern}

The field under validation must match the given regular expression.

**Note:** When using the `regex` pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

#### `required`
#### `required` {#required}

The field under validation must be present in the input data.

#### `required_if:_field_,_value_,...`
#### `required_if:_field_,_value_,...` {#required_if_field_value}

The field under validation must be present if the _field_ field is equal to any _value_.

#### `required_with:_foo_,_bar_,...`
#### `required_with:_foo_,_bar_,...` {#required_with_foo_bar}

The field under validation must be present _only if_ any of the other specified fields are present.

#### `required_with_all:_foo_,_bar_,...`
#### `required_with_all:_foo_,_bar_,...` {#required_with_all_foo_bar}

The field under validation must be present _only if_ all of the other specified fields are present.

#### `required_without:_foo_,_bar_,...`
#### `required_without:_foo_,_bar_,...` {#required_without_foo_bar}

The field under validation must be present _only when_ any of the other specified fields are not present.

#### `required_without_all:_foo_,_bar_,...`
#### `required_without_all:_foo_,_bar_,...` {#required_without_all_foo_bar}

The field under validation must be present _only when_ the all of the other specified fields are not present.

#### `same:_field_`
#### `same:_field_` {#same_field}

The specified _field_ value must match the field's value under validation.

#### `size:_value_`
#### `size:_value_` {#size_value}

The field under validation must have a size matching the given _value_. For string data, _value_ corresponds to the number of characters. For numeric data, _value_ corresponds to a given integer value. For files, _size_ corresponds to the file size in kilobytes.

#### `string:_value_`
#### `string:_value_` {#string_value}

The field under validation must be a string type.

#### `timezone`
#### `timezone` {#timezone}

The field under validation must be a valid timezone identifier according to the `timezone_identifiers_list` PHP function.

#### `unique:_table_,_column_,_except_,_idColumn_`
#### `unique:_table_,_column_,_except_,_idColumn_` {#unique_table_column_except_idcolumn}

The field under validation must be unique on a given database table. If the `column` option is not specified, the field name will be used.

#### Basic usage of unique rule
#### `Basic usage of unique rule`

```php
'email' => 'unique:users'
Expand All @@ -420,13 +420,13 @@ The field under validation must be unique on a given database table. If the `col
'email' => 'unique:users,email_address'
```

#### Forcing a unique rule to ignore a given ID
#### `Forcing a unique rule to ignore a given ID`

```php
'email' => 'unique:users,email_address,10'
```

#### Adding additional where clauses
#### `Adding additional where clauses`

You may also specify more conditions that will be added as "where" clauses to the query:

Expand All @@ -436,7 +436,7 @@ You may also specify more conditions that will be added as "where" clauses to th

In the rule above, only rows with an `account_id` of `1` would be included in the unique check.

#### url
#### url {#url}

The field under validation must be formatted as an URL.

Expand Down