> For the complete documentation index, see [llms.txt](https://docs.kasko.io/kasko-frontend-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kasko.io/kasko-frontend-documentation/core-concepts/validation/validators.md).

# Using existing validators

KASKO Frontend Framework utilizes most of [Laravel Validators](https://laravel.com/docs/5.8/validation#available-validation-rules) with the addition of some KASKO validators. These validation rules are defined in [field definitions](/kasko-frontend-documentation/core-concepts/api-requests.md).

> **Note:** See "[Adding Custom Validators](/kasko-frontend-documentation/core-concepts/validation/custom-validators.md)" for more information how to add product-specific custom validators.

## Available [Laravel Validators](https://laravel.com/docs/5.8/validation#available-validation-rules)

* [after](https://laravel.com/docs/5.8/validation#rule-after)
* [sometimes](https://laravel.com/docs/5.8/validation#rule-sometimes)
* [after\_or\_equal](https://laravel.com/docs/5.8/validation#rule-after-or-equal)
* [alpha\_num](https://laravel.com/docs/5.8/validation#rule-alpha-num)
* [before](https://laravel.com/docs/5.8/validation#rule-before)
* [before\_or\_equal](https://laravel.com/docs/5.8/validation#rule-before-or-equal)
* [email](https://laravel.com/docs/5.8/validation#rule-email)
* [gt](https://laravel.com/docs/5.8/validation#rule-gt)
* [gte](https://laravel.com/docs/5.8/validation#rule-gte)
* [in](https://laravel.com/docs/5.8/validation#rule-in)
* [max](https://laravel.com/docs/5.8/validation#rule-max)
* [min](https://laravel.com/docs/5.8/validation#rule-min)
* [not\_in](https://laravel.com/docs/5.8/validation#rule-not-in)
* [regex](https://laravel.com/docs/5.8/validation#rule-regex)
* [required](https://laravel.com/docs/5.8/validation#rule-required)
* [required\_if](https://laravel.com/docs/5.8/validation#rule-required-if)
* [required\_without](https://laravel.com/docs/5.8/validation#rule-required-without)
* [size](https://laravel.com/docs/5.8/validation#rule-size)

Available data types (variables will be converted prior to sending to the API, but are not validated in frontend):

* [string](https://laravel.com/docs/5.8/validation#rule-string)
* [integer](https://laravel.com/docs/5.8/validation#rule-integer)
* [boolean](https://laravel.com/docs/5.8/validation#rule-boolean)
* [number](https://laravel.com/docs/5.8/validation#rule-number) - Decimal numbers (alias: `numeric`)
* `numeric` - Decimal numbers (alias of `number`)
* [array](https://laravel.com/docs/5.8/validation#rule-array)
* `iso_date` - Date (YYYY-MM-DD format)
* `iso_datetime` - Date + time
* `email` - Email address
* `phone_number` - Phone number
* `dataset` - Dataset reference

## Available KASKO Validators

### alnum\_dash

Alpha-numeric characters and dash is allowed.

### alnum\_dash\_slash

Alpha-numeric characters, dash and forward slash is allowed.

### alnum\_space

Alpha-numeric characters and space is allowed.

### contains\_blacklist\_string

Fails validation if the given input matches a value in the blacklist.

```
contains_blacklist_string:hello,world
```

| Value                  | Validation passes? |
| ---------------------- | ------------------ |
| 1hello                 | No                 |
| This is my hello text. | No                 |

### contains\_exact\_blacklist\_string

Fails validation if the given input exactly matches a value in the blacklist (full words).

```
contains_exact_blacklist_string:hello,world
```

| Value                  | Validation passes? |
| ---------------------- | ------------------ |
| 1hello                 | Yes                |
| This is my hello text. | No                 |

### divisible\_without\_remainder

Check if the input value is divisible by X without a remainder.

```
divisible_without_remainder:100
```

| Value | Validation passes? |
| ----- | ------------------ |
| 123   | No                 |
| 12300 | Yes                |

### each\_word\_capitalized

Check if each word in the input is capitalized.

| Value       | Validation passes? |
| ----------- | ------------------ |
| hello World | No                 |
| Hello World | Yes                |

### iso\_date

Check if the input is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date.

### iso\_datetime

Check if the input is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime.

### required\_false

Input must be `false` to pass the validation.

### required\_false\_if

Input must be `false` if additional field match the given value.

```
required_false_if:data.additional_info,true
```

### required\_if\_all\_false

Input under validation is required if all other (given) fields are `false`.

```
required_if_all_false:data.field_two,data.field_three
```

### required\_if\_and

Input under validation is required if all other (given) fields match the given values.

```
required_if_and:data.other_field_name,other_field_value,data.another_field_name,another_field_value
```

### required\_true

> **Deprecated:** `required_true` should no longer be used because there is no backend support for it. Please use the `accepted` validation rule instead.

Input must be `true` to pass the validation.

### required\_true\_if

Input must be `true` if additional field match the given value.

```
required_true_if:data.additional_info,value
```

### required\_true\_if\_and

Input must be `true` if all other (given) fields match the given values.

```
required_true_if_and:data.other_field_name,other_field_value,data.another_field_name,another_field_value
```

### sequential\_char\_limit

Check if input doesn't have more than (given) limit of sequential characters.

```
sequential_char_limit:3
```

### iban

Check if input has a valid iban code, for this validation we are using 3rd party library.

First check is done by our framework:

* can contain only `A-Z` and `0-9` (letters and numbers)

Next are 3rd party library checks:

* check if first 2 chars from IBAN is registered in 3rd party library's supported country codes list. You can find this list [here](https://github.com/arhs/iban.js/blob/master/iban.js#L218).
* if is, then check against selected country's IBAN length
* check against selected country's IBAN structure
* and then check and calculate MOD 97-10 of the passed IBAN as specified in ISO7064

### bic

Check if input has a valid bic code.

Code should consist from 8 to 11 chars. First 6 chars should be A-Z, next 2 should be A-Z or 0-9 and then last 3 are optional which should be A-Z or 0-9.

### imei

Check if input has a valid IMEI code - consists of 15 digits and is valid using Luhn formula.

### phone\_number

Check if input has a valid phone number

### interval\_before

Check if input value (date) is between the given time interval.

```
interval_before:data.trip_start_date,+91 days
```

value must be between time period trip\_start\_date and +91 days

### interval\_before\_or\_equal

Check if input value (date) is between the given time interval or equal.

### interval\_after

Check if input value (date) is between the given time interval.

```
interval_after_or_equal:data.policy_start_date,-100 years
```

value must be between time period -100 years and policy\_start\_date

### interval\_after\_or\_equal

Check if input value (date) is between the given time interval or equal.

### keyword\_blacklist

Fails validation if the given input matches a value in the blacklist. Validation is case sensitive and blacklisted keyword can be a sentence.

```
keyword_blacklist:hello,world,some text,. hello
```

| Value                    | Validation passes? |
| ------------------------ | ------------------ |
| 1hello                   | Yes                |
| This is my hello text.   | No                 |
| sometext                 | Yes                |
| Need to write some text. | No                 |
| . hello world            | No                 |

### all\_caps

Check if each letter in the input is capitalized.

### not\_all\_caps

Input value (string) can't have all capital letters.

| Value       | Validation passes? |
| ----------- | ------------------ |
| HeLLo WorLD | Yes                |
| HELLO WORLD | No                 |

### year

Input is validated against the provided rule which contains two arguments - a comparison operator and year.

```
year:>=,1890|year:<=,2000
```

### accepted

Input must be accepted (truthy value like `yes`, `on`, `1`, `true`). Used for consent fields.

### accepted\_if

Input must be accepted if another field matches the given value.

```
accepted_if:data.requires_consent,true
```

### accepted\_if\_and

Input must be accepted if all other (given) fields match the given values.

```
accepted_if_and:data.field_one,value1,data.field_two,value2
```

### alpha

Only alphabetic characters are allowed.

### case\_sensitivity

Case-sensitive matching validation.

### compare

Compare two fields using an operator.

```
compare:data.other_field,>=
```

### exclude\_unless

Exclude field from validation unless another field matches the given value. If condition is not met, the field is excluded from the request.

```
exclude_unless:data.show_field,true
```

### exclude\_unless\_and

Exclude field from validation unless all conditions are met.

```
exclude_unless_and:data.field_one,value1,data.field_two,value2
```

### payment

Payment-specific validation for payment fields.
