Type parameter | Description |
---|---|
TInputs: InputGroupContent |
the type of the "input shape". This can be an input type, an object of inputs, an array of inputs, or a nested structure thereof, or a function returning such a structure. |
TDomainValue |
the type of the domain value that is extracted from the input value for domain validation. |
TParseError |
the type that describes the error when trying to parse the input value into a domain value. |
TDomainError |
the type that describes the error resulting from validating the domain value. |
Instantiates a validator.
The input whose values will be needed in validation. This can be any arbitrary structure of input states.
Specifies additional options for the validator.
Development-time settings
Customizes input group behavior.
Specifies additional options for the validator.
Returns the correctional input value. This correction may arise from the parsing or from the domain validation (the former is favoured). If there is no correctional value (either because the domain validator/parser didn't give any or because the validation succeeded), this returns void.
Gets the validator's latest domain validation result. Note that if domain validation has never been triggered, this returns a success.
For a more conclusive check for input validity, use isConclusivelyValid and isConclusivelyInvalid.
Gets the validator's domain value. This value is undefined if the input value cannot be parsed.
Gets the validator's most recent error result. This maybe a domain error or a parse error. Use the key "errorType" to discriminate the kind of error. When there is no error encountered, null is returned.
Note that if the input value can be parsed and the domain validation has never been triggered, this returns null also. For a more conclusive check for input validity, use isConclusivelyValid and isConclusivelyInvalid.
Returns an array of the input group's structural items. Unlike [[flattenedInputs]], the subgroups are not broken down into inputs here.
Returns true if any of the inputs that the validator depends on is in a
"changed" state. Shorthand for checking that at least one input's hasChanged
is true.
Returns true if any of the inputs that the validator depends on has not been confirmed by the user.
Same as with value
but each value is the current input value, not the
confirmed input value.
Reflects the structure of inputs as provided in the constructor. If a function was passed in the constructor, it is evaluated here. Subgroups in the structures are collapsed into their structures.
Use structure if you need the subgroups preserved. Use [[flattenedInputs]] if you don't care about the structure and just want the inputs in an array.
Returns true if the validator is in a "conclusive" state: that is defined to mean that:
Returns true if the input can be taken to be conclusively invalid. That is, it has either failed the parser, or it is in all of these states:
Returns true if the input can be taken to be conclusively valid. That is, it is in all of these states:
Returns true if the validator is enabled for automatic validation. When this value is true,
Returns true if asynchronous domain validation is currently happening.
Returns true if the validator is "virgin": this is defined as follows:
Returns the UI state's debug name.
Returns the "nested" validators: these are the other validators that also depend on one of the inputs this validator is depending on.
Same as with value
but each value is the current input value, normalized
by each input's normalizer.
Gets validator's input parsing result. Use the "isError" key to discriminate between a successful parse (which will give you the domain value) and a failed parse (which will give you the parse error).
Returns the promise that resolves when the validation task is complete.
Returns the structure of the input group. If the input structure contains subgroups, the subgroups are preserved here.
Use inputs to get the input structure without subgroups.
Use [[flattenedInputs]] to get an array of inputs whose order does not matter.
Returns a structure of confirmed input value that corresponds to the input structure
passed to the constructor. For instance, if the constructor was instantiated
with { a : someInput, b: someOuterInput }
, the value here will also have the
keys a
and b
whose value are the respective input values.
Batch-confirm the inputs using the value that is provided in the group. Note that unlike individually confirming an input, this does not permit an option to advance the focus to the "next" input.
Format a domain value into an input value. This can be used to turn the domain correction into meaningful input values.
Domain value to format.
Try parsing an input value.
value to parse. This must match the value structure implied by the input structure.
Gets the validator's domain value, assuming that the parsing has succeeded. Use this to bypass checking for successful parse, but it will throw an error if the parse has actually failed.
Batch-reset the inputs using the value that is provided in the group. This is the same as calling reset on the individual input instances.
Triggers validation.
If the input cannot be parsed, this is no-op. If there is pending validation from the previous trigger, that previous validation is canceled. While validation is going on, if the input value has changed such that it now cannot be parsed, the pending validation is canceled.
Generated using TypeDoc
Represents a state for form input validation. This includes bookkeeping of whether the validation has ever happened, what the most recent validation result was, and whether asynchronous validation is happening on right now.