Class: __validationUnit

is.__validationUnit() → {Object}

new __validationUnit() → {Object}

Function to return a new configurable validator. You don't need to call this directly! Use a factory method instead.
Source:
Returns:
The new, unconfigured validator.
Type
Object

Methods

ArrayOf(schema) → {is.__validationUnit}

Set the validator to validate arrays.
Parameters:
Name Type Description
schema is.__validationUnit The validator which must validate every element of the array.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

Boolean() → {is.__validationUnit}

Set the validator to validate booleans.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

Number() → {is.__validationUnit}

Set the validator to validate numbers.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

Object(schemaObj) → {is.__validationUnit}

Set the validator to validate objects.
Parameters:
Name Type Description
schemaObj Object The schema of the object to validate, made up of other validators.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

OneOf(schemaArray) → {is.__validationUnit}

Set the validator to validate a variable type.
Parameters:
Name Type Description
schemaArray is.__validationUnit An array of other validators.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

optional() → {is.__validationUnit}

Set the validator to optional, so it accepts missing values.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

String() → {is.__validationUnit}

Set the validator to validate strings.
Source:
Returns:
The validator itself.
Type
is.__validationUnit

validate(subject) → {Boolean}

Validate the subject against the set schema.
Parameters:
Name Type Description
subject any The subject to validate.
Source:
Returns:
Validation result: true if the subject matches the schema, false otherwise.
Type
Boolean

Which(lambda) → {is.__validationUnit}

Add a new functional validation lambda to the validator.
Parameters:
Name Type Description
lambda lambda The functional validator, which accesses the subject and returns true or false.
Source:
Returns:
The validator itself.
Type
is.__validationUnit