Parsley: Built-in validators Cheat Sheet

Built-in validators list

NameAPIDescription
Required required
data-parsley-required
data-parsley-required="true"
data-parsley-required="false"
Validates that a required field has been filled with a non blank value. If data-parsley-required="false", validator is deactivated and the field is not required.
Email type="email"
data-parsley-type="email"
Validates that a value is a valid email address.
Numberdata-parsley-type="number"Validates that a value is a valid number according to the given stepmin and original value.
The default step for HTML5 is “1”, which is so counterintuive that Parsley uses a default step of “any” for data-parsley-type="number"
Integer type="number"
data-parsley-type="integer"
Validates that a value is a valid integer.
Digits data-parsley-type="digits"Validates that a value is only digits.
Alphanum data-parsley-type="alphanum"Validates that a value is a valid alphanumeric string.
Urltype="url"
data-parsley-type="url"
Validates that a value is a valid url.
Minlength minlength="6"
data-parsley-minlength="6"
Validates that the length of a string is at least as long as the given limit.
Maxlengthmaxlength="10"
data-parsley-maxlength="10"
Validates that the length of a string is not longer than the given limit.
Length data-parsley-length="[6, 10]"Validates that a given string length is between some minimum and maximum value.
Min min="6"
data-parsley-min="6"
Validates that a given input (number or date) or date is greater than or equal to some minimum (number or date.)
Max max="10"
data-parsley-max="10"
Validates that the given input (number or date) is less than or equal to some maximum value (number or date).
Rangetype="range"
data-parsley-range="[6, 10]"
Validates that a given value (number or date) is between some minimum and maximum values (numbers or dates).
Pattern pattern="\d+"
data-parsley-pattern="\d+"
Validates that a value matches a specific regular expression (regex).
MinCheck data-parsley-mincheck="3"Validates that a certain minimum number of checkboxes in a group are checked.
MaxCheck data-parsley-maxcheck="3"Validates that a certain maximum number of checkboxes in a group are checked.
Check data-parsley-check="[1, 3]"Validates that the number of checked checkboxes in a group is within a certain range.
Equaltodata-parsley-equalto="#anotherfield"Validates that the value is identical to another field’s value (useful for password confirmation check).

Type Constraints

NameAPIDescription
Emailparsley-type="email"

type="email"
Validates that a value is a valid email address.
Urlparsley-type="url" type="url"Validates that a value is a valid url.
Url strictparsley-type="urlstrict"Validates that a value is a valid strict URL, ie: with one of httphttpsftpgit allowed protocols.
Digitsparsley-type="digits"Validates that a value is only digits.
Numberparsley-type="number"

type="number"
Validates that a value is a valid number.
Alphanumparsley-type="alphanum"Validates that a value is a valid alphanumeric string.
Date Isoparsley-type="dateIso"Validates that a value is a valid ISO date.
Phone 
tel
parsley-type="phone"Validates that a value is a valid phone number.

Extra Validators

The list of parsley.extra validators

NameApiDescription
Min Wordsparsley-minwords="6"Validate that a field has at least 6 words.
Max Wordsparsley-maxwords="6"Validate that a field has 6 words maximum.
Range Wordsparsley-rangewords="[6,10]"Validate that a field has between 6 and 10 words.
Greater Thanparsley-greaterthan="#elem"Validate that a field’s value is greater than #elem’s value.
Less Thanparsley-lessthan="#elem"Validate that a field’s value is lower than #elem’s value.
Before dateparsley-beforedate="#elem"Validate that a field’s date is before #elem’s date.
On or before dateparsley-onorbeforedate="#elem"Validate that a field’s date is on or before #elem’s date.
After dateparsley-afterdate="#elem"Validate that a field’s date is after #elem’s date.
On or after dateparsley-onorafterdate="#elem"Validate that a field’s date is on or after #elem’s date.
In listparsley-inlist="foo, bar, foo bar"Validates that a field’s value is present within the value list. You can define the delimiter using parsley-inlist-delimiter=",". Delimiter defaults to ",".
Luhnparsley-luhn="true"Validates that a fields value passes the Luhn algorithm. Validates credit card numbers, as well as some other kinds of account numbers.
American Dateparsley-americandate="true"Validates that a value is a valid American Date. Allows for slash, dot and hyphen delimiters and condensed dates (e.g., M/D/YY MM.DD.YYYY MM-DD-YY).

Leave a Reply

Your email address will not be published. Required fields are marked *