Basic Types

array

Validates that the field under validation is an array.

const rules = {
 foo: "array",
};

object:list,of,keys

The field under validation must be a typescript object. if keys specified, all of the keys must exist in the object.

const rules = {
 foo: "required|object:key1,key2", // object must be { "key1": 1, "key2": 2 }
};

boolean

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

const rules = {
 foo: "boolean",
};

date

Validates that the field under validation is a date.

const rules = {
 foo: "date",
};

decimal:min, max

The field under validation must be numeric and must contain the specified number of decimal places:

const rules = {
 foo: "required|decimal:2",
 bar: "sometimes|decimal:2,4",
};

integer

Validates that the field under validation is an integer.

const rules = {
 foo: "integer",
};

json

Validates that the field under validation is a valid JSON string.

const rules = {
 foo: "json",
};

numeric

Validates that the field under validation is numeric.

const rules = {
 foo: "numeric",
};

string

Validates that the field under validation is a string.

const rules = {
 foo: "string",
};