Home How it Works Components Validation Spam Cloud Emails Pricing Docs API Docs Sign In Try It Free

Validation Rules


accepted

The field under validation must be yes, on, 1, or true. This is useful for validating "Terms of Service" acceptance.

<div class="kw-checkbox-group" rules="accepted">
      <input type="checkbox" name="terms" value="true" label="I accept the terms and conditions">
</div>

after_or_equal:date

The field under validation must be a value after or equal to the given date.

<input type="datepicker" name="date" rules="after_or_equal:June 06, 2019">

alpha

The field under validation must be entirely alphabetic characters.

<input type="text" name="username" rules="alpha">

alpha_dash

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

<input type="text" name="username" rules="alpha_dash">

alpha_num

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

<input type="text" name="username" rules="alpha_num">

array

The field under validation must be an array.




<div class="kw-checkbox-group" rules="array">
      <input type="checkbox" name="fruits" value="Apple" label="Apple">
      <input type="checkbox" name="fruits" value="Orange" label="Orange">
      <input type="checkbox" name="fruits" value="Kiwi" label="Kiwi">
</div>


bail

Stop running validation rules after the first validation failure.

<input type="text" name="number" rules="bail|required|numeric">

before:date

The field under validation must be a value preceding the given date. Like the after rule, the name of another field under validation may be supplied as the value of date.

<input type="datepicker" name="date" rules="before:June 06, 2019">

between:min,max

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

If the field under validation is numeric, make sure to add the rule numeric like we did below. That way it is not checked as a string.

<input type="number" name="number" rules="between:5,10|numeric">

boolean

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


<div class="kw-radio-group" rules="boolean">
      <input type="radio" name="boolean" value="1" label="True">
      <input type="radio" name="boolean" value="0" label="False">
</div>

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.

<input type="password" name="password" rules="required|confirmed">
<input type="password" name="password_confirmation" rules="required">

date

The field under validation must be a valid, non-relative date.

<input type="datepicker" name="date" rules="date">

different:field

The field under validation must have a different value than field.

<select name="firstField" rules="required">
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
</select>

<select name="secondField" rules="required|different:firstField">
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
</select>

digits:value

The field under validation must be numeric and must have an exact length of value.

<input type="number" name="digitNumber" rules="digits:4">

digits_between:min,max

The field under validation must have a length between the given min and max.

<input type="number" name="digitNumber" rules="digits_between:2,5">

email

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

<input type="email" name="email" rules="email">

file

The field under validation must be a successfully uploaded file.


filled

The field under validation must not be empty when it is present.


gt:field

The field under validation must be greater than the given field. The two fields must be of the same type. Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule.


gte:field

The field under validation must be greater than or equal to the given field. The two fields must be of the same type. Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule.


image

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


in_array:anotherfield.*

The field under validation must exist in anotherfield's values.


integer

The field under validation must be an integer.


ip

The field under validation must be an IP address.


ipv4

The field under validation must be an IPv4 address.


ipv6

The field under validation must be an IPv6 address.


json

The field under validation must be a valid JSON string.


lt:field

The field under validation must be less than the given field. The two fields must be of the same type. Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule.


lte:field

The field under validation must be less than or equal to the given field. The two fields must be of the same type. Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule.


max:value

The field under validation must be less than or equal to a maximum value. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.


mimetypes:text/plain,...

The file under validation must match one of the given MIME types:

To determine the MIME type of the uploaded file, the file's contents will be read and the framework will attempt to guess the MIME type, which may be different from the client provided MIME type.


mimes:foo,bar,...

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

Even though you only need to specify the extensions, this rule actually validates against the MIME type of the file by reading the file's contents and guessing its MIME type.

A full listing of MIME types and their corresponding extensions may be found at the following location: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types


min:value

The field under validation must have a minimum value. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.


not_regex:pattern

The field under validation must not match the given regular expression.

Internally, this rule uses the PHP preg_match function. The pattern specified should obey the same formatting required by preg_match and thus also include valid delimiters. For example: rules="not_regex:/^.+$/i"

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


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

The field under validation must be numeric.


present

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


regex:pattern

The field under validation must match the given regular expression.

Internally, this rule uses the PHP preg_match function. The pattern specified should obey the same formatting required by preg_match and thus also include valid delimiters. For example: rules="regex:/^.+@.+$/i"

Note: When using the regex / not_regex patterns, 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

The field under validation must be present in the input data and not empty. A field is considered "empty" if one of the following conditions are true:

The value is null. The value is an empty string. The value is an empty array or empty Countable object. The value is an uploaded file with no path.


required_if:anotherfield,value,...

The field under validation must be present and not empty if the anotherfield field is equal to any value.


required_unless:anotherfield,value,...

The field under validation must be present and not empty unless the anotherfield field is equal to any value.


required_with:foo,bar,...

The field under validation must be present and not empty only if any of the other specified fields are present.


required_with_all:foo,bar,...

The field under validation must be present and not empty only if all of the other specified fields are present.


required_without:foo,bar,...

The field under validation must be present and not empty only when any of the other specified fields are not present.


required_without_all:foo,bar,...

The field under validation must be present and not empty only when all of the other specified fields are not present.


same:field

The given field must match the field under validation.


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 an array, size corresponds to the count of the array. For files, size corresponds to the file size in kilobytes.


starts_with:foo,bar,...

The field under validation must start with one of the given values.


string

The field under validation must be a string. If you would like to allow the field to also be null, you should assign the nullable rule to the field.


timezone

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


url

The field under validation must be a valid URL.


uuid

The field under validation must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID).