new __validationUnit() → {Object}
Function to return a new configurable validator. You don't need to call this directly! Use a factory method instead.
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. |
Returns:
The validator itself.
- Type
- is.__validationUnit
Boolean() → {is.__validationUnit}
Set the validator to validate booleans.
Returns:
The validator itself.
- Type
- is.__validationUnit
Number() → {is.__validationUnit}
Set the validator to validate numbers.
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. |
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. |
Returns:
The validator itself.
- Type
- is.__validationUnit
optional() → {is.__validationUnit}
Set the validator to optional, so it accepts missing values.
Returns:
The validator itself.
- Type
- is.__validationUnit
String() → {is.__validationUnit}
Set the validator to validate strings.
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. |
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. |
Returns:
The validator itself.
- Type
- is.__validationUnit