new Validator(field, type, optional, function, validatorFactory) → {Validator}
| Name | Type | Description |
|---|---|---|
field | string | the UI field to validate. |
type | string | type of validator. |
optional | boolean | set the validation result as optional. |
function | vfunc | validation function. |
validatorFactory | ValidatorFactory | a ValidatorFactory instance. |
- Source
a Validator instance.
- Type:
- Validator
Methods
apply(name, value, args) → {*}
Apply a validation function by name or directly via function reference. If a name is provided it resolves it via the factory's registered types.
| Name | Type | Description |
|---|---|---|
name | string | | Validator name or function. |
value | * | Value to validate (optional; defaults to field value). |
args | Array | Arguments passed to the validator function. |
- Source
Validator result.
- Type:
- *
assert(condition, message) → {boolean}
Assert a condition and update field error state.
| Name | Type | Description |
|---|---|---|
condition | boolean | Condition that must be true. |
message | string | Error message when assertion fails. |
- Source
True when assertion is true, false otherwise.
- Type:
- boolean
validate() → {boolean}
Validate the associated field value using the compiled validator stack and any additional validators provided at construction time. Emits 'validation-failure' or 'validation-success' CustomEvents on the field.
- Source
True if validation succeeds, false otherwise.
- Type:
- boolean