# Quick reference for `checkit` validators

<p class="callout info">This article was originally published at [https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589).</p>

### Presence[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#presence)

- **exists -** The field must exist, and not be `undefined`.
- **required -** The field must exist, and not be `undefined`, `null` or an empty string.
- **empty -** The field must be some kind of "empty". Things that are considered "empty" are as follows: 
    - `""` (empty string)
    - `[]` (empty array)
    - `{}` (empty object)
    - Other falsey values

### Character set[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#character-set)

- **alpha -** `a-z`, `A-Z`
- **alphaNumeric -** `a-z`, `A-Z`, `0-9`
- **alphaUnderscore -** `a-z`, `A-Z`, `0-9`, `_`
- **alphaDash -** `a-z`, `A-Z`, `0-9`, `_`, `-`

### Value[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#value)

Length-related validators may apply to both strings and arrays.

- **exactLength:`length`-** The value must have a length of exactly `length`.
- **minLength:`length` -** The value must have a length of at least `length`.
- **maxLength:`length` -** The value must have a length of at most `length`.
- **contains:`needle` -** The value must contain the specified `needle` (applies to both strings and arrays).
- **accepted -** Must be a value that indicates agreement - varies by language (defaulting to `en`): 
    - **en, fr, nl -** `"yes"`, `"on"`, `"1"`, `1`, `"true"`, `true`
    - **es -** `"yes"`, `"on"`, `"1"`, `1`, `"true"`, `true`, `"si"`
    - **ru -** `"yes"`, `"on"`, `"1"`, `1`, `"true"`, `true`, `"да"`

### Value (numbers)[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#value-numbers)

Note that "numbers" refers to both Number-type values, and strings containing numeric values!

- **numeric -** Must be a finite numeric value of some sort.
- **integer -** Must be an integer value (either positive or negative).
- **natural -** Must be a natural number (ie. an integer value of 0 or higher).
- **naturalNonZero -** Must be a natural number, but *higher* than 0 (ie. an integer value of 1 or higher).
- **between:`min`:`max` -** The value must numerically be between the `min` and `max` values (exclusive).
- **range:`min`:`max` -** The value must numerically be *within* the `min` and `max` values (inclusive).
- **lessThan:`maxValue` -** The value must numerically be less than the specified `maxValue` (exclusive).
- **lessThanEqualTo:`maxValue` -** The value must numerically be less than *or equal to* the specified `maxValue` (inclusive).
- **greaterThan:`minValue` -** The value must numerically be greater than the specified `minValue` (exclusive).
- **greaterThanEqualTo:`minValue` -** The value must numerically be greater than *or equal to* the specified `minValue` (inclusive).

### Relations to other fields[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#relations-to-other-fields)

- **matchesField:`field` -** The value in this field must equal the value in the specified other `field`.
- **different:`field` -** The value in this field must *not* equal the value in the specified other `field`.

### JavaScript types[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#javascript-types)

- **NaN -** Must be `NaN`.
- **null -** Must be `null`
- **string -** Must be a `String`.
- **number -** Must be a `Number`.
- **array -** Must be an `Array`.
- **plainObject -** Must be a plain `object` (ie. object literal).
- **date -** Must be a `Date` object.
- **function -** Must be a `Function`.
- **regExp -** Must be a `RegExp` object.
- **arguments -** Must be an `arguments` object.

### Format[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"></svg>](https://gist.github.com/joepie91/cd107b3a566264b28a3494689d73e589#format)

- **email -** Must be a validly formatted e-mail address.
- **luhn -** Must be a validly formatted creditcard number (according to a Luhn regular expression).
- **url -** Must be a validly formatted URL.
- **ipv4 -** Must be a validly formatted IPv4 address.
- **ipv6 -** Must be a validly formatted IPv6 address.
- **uuid -** Must be a validly formatted UUID.
- **base64 -** Must be a validly formatted base64 string.