-
Notifications
You must be signed in to change notification settings - Fork 55
Available Validators (rules)
All validators are written as snake_case but it's up to the user's taste and could also be used as camelCase. So for example alpha_dash_spaces and alphaDashSpaces are both equivalent.
NOTE: on an input type="number", the + sign is an invalid character (browser restriction) even if you are using a signed validator. If you really wish to use the +, then change your input to a type="text".
-
acceptedThe field under validation must beyes,on,1, ortrue. Useful for validating "Terms of Service" acceptance. -
alphaOnly alpha characters (including latin) are present (a-z, A-Z) -
alpha_spacesOnly alpha characters (including latin) and spaces are present (a-z, A-Z) -
alpha_numOnly alpha-numeric characters (including latin) are present (a-z, A-Z, 0-9) -
alpha_num_spacesOnly alpha-numeric characters (with latin & spaces) are present (a-z, A-Z, 0-9) -
alpha_dashOnly alpha-numeric characters + dashes, underscores are present (a-z, A-Z, 0-9, _-) -
alpha_dash_spacesAlpha-numeric chars + dashes, underscores and spaces (a-z, A-Z, 0-9, _-) -
between:min,maxWill auto-detect value type then use proper validator.- Type Number uses
between_num, String usebetween_len.
- Type Number uses
-
between_date_iso:d1,d2Alias ofbetween_date_iso. -
between_date_euro_long:d1,d2Alias ofdate_euro_long_between. -
between_date_euro_short:d1,d2Alias ofdate_euro_short_between. -
between_date_us_long:d1,d2Alias ofdate_us_long_between. -
between_date_us_short:d1,d2Alias ofdate_us_short_between. -
between_len:min,maxEnsures the length of a string is between a min,max length. -
between_num:min,maxEnsures the numeric value (int or float) is between a min,max number. -
booleanEnsures the value istrueorfalse(0or1is also valid). -
compareAlias ofmatch -
credit_cardValid credit card number (AMEX, VISA, Mastercard, Diner's Club, Discover, JCB) -
date_isoEnsure date follows the ISO format (yyyy-mm-dd) -
date_iso_between:d1,d2Ensure date follows the ISO format and is between (d1) & (d2) -
date_iso_max:dDate must follow ISO format and is lower or equal than date (d) -
date_iso_min:dDate must follow ISO format and is higher or equal than date (d) -
date_euro_longDate must follow the European long format (dd-mm-yyyy) or (dd/mm/yyyy) -
date_euro_long_between:d1,d2Date must follow European long format and is between (d1) & (d2) -
date_euro_long_max:dDate must follow European long format and is lower or equal than date (d) -
date_euro_long_min:dDate must follow European long format and is higher or equal than date (d) -
date_euro_shortDate must follow the Euro short format (dd-mm-yy) or (dd/mm/yy) -
date_euro_short_between:d1,d2Date must follow Euro short format and is between (d1) & (d2) -
date_euro_short_max:dDate must follow Euro short format and is lower or equal than date (d) -
date_euro_short_min:dDate must follow Euro short format and is higher or equal than date (d) -
date_us_longDate must follow the US long format (mm-dd-yyyy) or (mm/dd/yyyy) -
date_us_long_between:d1,d2Date must follow the US long format and is between (d1) & (d2) -
date_us_long_max:dDate must follow US long format and is lower or equal than date (d) -
date_us_long_min:dDate must follow US long format and is higher or equal than date (d) -
date_us_shortDate must follow the US short format (mm-dd-yy) or (mm/dd/yy) -
date_us_short_between:d1,d2Date must follow the US short format and is between (d1) & (d2) -
date_us_short_max:dDate must follow US short format and is lower or equal than date (d) -
date_us_short_min:dDate must follow US short format and is higher or equal than date (d) -
differentAlias ofdifferent_input -
different_input:fMust be different from another input field(f), where (f) must be the exact ngModel attribute of input field to compare to. The error message will use the input name or thefriendly-nameif it was provided on first input, ex.:<input friendly-name="First Name".../>will display :: Field must be different from specified field "First Name". -
different_input:f,tMust be different from another input field(f), same as (different:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should usematch:n:altsee :alt) -
digits:nEnsures that field only has integer numbers and length precisely matches the specified length (n). -
digits_between:min,maxEnsures that field only has integer numbers and is between a min,max length. -
emailChecks for a valid email address -
email_addressAlias ofemail -
enumAlias ofin_list -
exact_len:nEnsures that field length precisely matches the specified length (n). -
floatas to be floating value (excluding integer) -
float_signedHas to be floating value (excluding int), could be signed (-/+) positive/negative. -
To properly validate an IBAN please use Wiki - Custom Validation with an external library like Github arhs/iban.jsiban -
inAlias ofin_list -
in_list:foo,bar,..Ensures the value is included inside the given list of values. The list must be separated by ',' and also accept words with spaces for example "ice cream". -
intOnly positive integer (alias tointeger). -
integerOnly positive integer. -
int_signedOnly integer, could be signed (-/+) positive/negative (alias tointeger_signed). -
integer_signedOnly integer, could be signed (-/+) positive/negative. -
ipAlias ofipv4 -
ipv4Check for valid IP (IPv4) -
ipv6Check for valid IP (IPv6) -
match:fMatch another input field(f), where (f) must be the exact ngModel attribute of input field to compare to. The error message will use thefriendly-nameif it was provided on first input, ex.:<input friendly-name="Password".../>will display :: Confirmation field does not match specified field "Password". -
match:f,tMatch another input field(f), same as (match:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should usematch:n:altsee :alt) -
match_inputAlias ofmatch. -
max:nWill auto-detect value type then use proper validator.- Type Number uses
max_num, String usemax_len.
- Type Number uses
-
max_date_isoAlias ofdate_iso_max. -
max_date_euro_longAlias ofdate_euro_long_max. -
max_date_euro_shortAlias ofdate_euro_short_max. -
max_date_us_longAlias ofdate_us_long_max. -
max_date_us_shortAlias ofdate_us_short_max. -
max_len:nChecks field length, no longer than specified length where (n) is length parameter. -
max_length:nAlias ofmax_len -
max_num:nChecks numeric value to be lower or equal than the number (n). -
min:nWill auto-detect value type then use proper validator.- Type Number uses
min_num, String usemin_len.
- Type Number uses
-
min_date_isoAlias ofdate_iso_min. -
min_date_euro_longAlias ofdate_euro_long_min. -
min_date_euro_shortAlias ofdate_euro_short_min. -
min_date_us_longAlias ofdate_us_long_min. -
min_date_us_shortAlias ofdate_us_short_min. -
min_len:nChecks field length, no shorter than specified length where (n) is length parameter. -
min_length:nAlias ofmin_len -
min_num:nChecks numeric value to be higher or equal than the number (n). -
not_inAlias ofnot_in_list -
not_in_list:foo,bar,..Ensures the value is included inside the given list of values. The list must be separated by ',' and also accept words with spaces for example "ice cream". -
numericOnly positive numeric value (float, integer). -
numeric_signedOnly numeric value (float, integer) can also be signed (-/+). -
patternEnsure it follows a regular expression pattern... Refer to Wiki - Regular Expression Pattern on how to use it. -
phoneCheck for a valid phone number (Canada/US) -
phone_internationalCheck for a valid international phone number -
rangeAlias ofbetween -
requiredEnsures the specified key value exists and is not empty -
sameAlias ofmatch. -
sizeWill auto-detect value type then use proper validator.- Type Number uses
exact_num, String useexact_len.
- Type Number uses
-
string_lenAlias ofbetween_len -
string_lengthAlias ofbetween_len -
timeEnsure time follows the format of (hh:mm) or (hh:mm:ss) -
urlCheck for valid URL or subdomain
Contents
- Angular-Validation Wiki
- Installation
- Demo
- Code Samples
- Functionalities
- Custom Validations
- Properties & Options
- Validators
- Tests
- Misc