CollectionValidator
Hierarchy
PatternValidator
↳ CollectionValidator
Implements
- PatternValidator
- PatternValidator
Index
Properties
Methods
Properties
Static describer
▪ describer: Describer
Inherited from PatternValidator.describer
Overrides void
Methods
canValidate
▸ canValidate(expectation: Expectation, isStrict?: boolean): boolean
Implementation of PatternValidator
Evaluates if validator can handle provided explicit pattern or implicit expectation.
Parameters:
| Name | Type | Description |
|---|---|---|
expectation | Expectation | Evaluated explicit Pattern instance or implicit expectation. |
isStrict? | boolean | - |
Returns: boolean
Returns true if pattern is instance of Collection or is plain Object validated in strict mode, else false.
describe
▸ describe(value: any): string
Inherited from PatternValidator.describe
Overrides void
Parameters:
| Name | Type |
|---|---|
value | any |
Returns: string
validate
▸ validate(value: any, collOrExpect: Collection | Record‹keyof any, any›, validator: Validator): boolean
Validates an Object with the given keys and with values matching the given
patterns. The value must not contain any arbitrary keys(not listed in the pattern).
The value must be a plain Object or class instance.
throws {InvalidTypeError}
Thrown if the value is not an object, instance of Collection or class.
throws {UnexpectedKeyError}
Thrown if the value has unexpected key.
throws {ValidationError}
Thrown if the value does not match expected properties.
Parameters:
| Name | Type | Description |
|---|---|---|
value | any | Value that is validated against expectation.. |
collOrExpect | Collection | Record‹keyof any, any› | Explicit pattern as Collection instance or implicit expectation as plain object against which value is validated. |
validator | Validator | Validator matching Validator interface. |
Returns: boolean
Returns true if value is matching explicit Collection pattern or implicit expectation as plain object, else throws.
Static getDescriber
▸ getDescriber(): Describer
Inherited from PatternValidator.getDescriber
Overrides void
Returns: Describer
Static setDescriber
▸ setDescriber(describer: Describer): void
Inherited from PatternValidator.setDescriber
Overrides void
Parameters:
| Name | Type |
|---|---|
describer | Describer |
Returns: void