The state for a field.
▪ TValue
-
↳ FieldState
- ComposibleValidatable‹TValue›
+ new FieldState(initialValue
: TValue, delay
: number): FieldState
Overrides Disposable.constructor
Defined in fieldState.ts:230
Parameters:
Name | Type | Default |
---|---|---|
initialValue |
TValue | - |
delay |
number | 200 |
Returns: FieldState
• $: TValue
Implementation of ComposibleValidatable.$
Defined in fieldState.ts:39
Value that has bean validated with no error, AKA "safe".
• _activated: boolean = false
Implementation of ComposibleValidatable._activated
Defined in fieldState.ts:15
If activated (with auto validation).
Field will only be activated when validate()
or onChange()
called.
• _error? : undefined | string
Defined in fieldState.ts:64
The original error info of validation.
• _validateStatus: ValidateStatus = ValidateStatus.NotValidated
Implementation of ComposibleValidatable._validateStatus
Defined in fieldState.ts:52
The validate status.
• _value: TValue
Defined in fieldState.ts:28
Value that reacts to onChange
immediately.
You should only use it to bind with UI input componnet.
• value: TValue
Implementation of ComposibleValidatable.value
Defined in fieldState.ts:34
Value that can be consumed by your code.
It's synced from _value
with debounce of 200ms.
• get dirty(): boolean
Defined in fieldState.ts:20
If value has been touched (different with initialValue
)
Returns: boolean
• get error(): undefined | string
Defined in fieldState.ts:69
The error info of validation.
Returns: undefined | string
• get hasError(): boolean
Defined in fieldState.ts:76
If the state contains error.
Returns: boolean
• get validated(): boolean
Defined in fieldState.ts:84
If the validation has been done. It does not means validation passed.
Returns: boolean
• get validating(): boolean
Defined in fieldState.ts:57
If the state is doing a validation.
Returns: boolean
▸ disableValidationWhen(predict
: function): this
Defined in fieldState.ts:199
Configure when to disable validation.
Parameters:
▪ predict: function
▸ (): boolean
Returns: this
▸ dispose(): void
Inherited from Disposable.dispose
Defined in disposable.ts:23
Do dispose by calling all disposer functions.
Returns: void
▸ onChange(value
: TValue): void
Defined in fieldState.ts:119
Set _value
on change event.
Parameters:
Name | Type |
---|---|
value |
TValue |
Returns: void
▸ reset(): void
Defined in fieldState.ts:134
Reset to initial status.
Returns: void
▸ set(value
: TValue): void
Defined in fieldState.ts:126
Set value
(& _value
) synchronously.
Parameters:
Name | Type |
---|---|
value |
TValue |
Returns: void
▸ setError(error
: ValidationResponse): void
Defined in fieldState.ts:91
Set error info.
Parameters:
Name | Type |
---|---|
error |
ValidationResponse |
Returns: void
▸ validate(): Promise‹object | object›
Implementation of ComposibleValidatable
Defined in fieldState.ts:171
Fire a validation behavior.
Returns: Promise‹object | object›
▸ validators(...validators
: Validator‹TValue›[]): this
Defined in fieldState.ts:103
Add validator function.
Parameters:
Name | Type |
---|---|
...validators |
Validator‹TValue›[] |
Returns: this