Skip to content

Latest commit

 

History

History
334 lines (183 loc) · 7.18 KB

fieldstate.md

File metadata and controls

334 lines (183 loc) · 7.18 KB

formstate-xFieldState

Class: FieldState <TValue>

The state for a field.

Type parameters

TValue

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ 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

Properties

$

$: TValue

Implementation of ComposibleValidatable.$

Defined in fieldState.ts:39

Value that has bean validated with no error, AKA "safe".


_activated

_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.


Optional _error

_error? : undefined | string

Defined in fieldState.ts:64

The original error info of validation.


_validateStatus

_validateStatus: ValidateStatus = ValidateStatus.NotValidated

Implementation of ComposibleValidatable._validateStatus

Defined in fieldState.ts:52

The validate status.


_value

_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

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.

Accessors

dirty

get dirty(): boolean

Defined in fieldState.ts:20

If value has been touched (different with initialValue)

Returns: boolean


error

get error(): undefined | string

Defined in fieldState.ts:69

The error info of validation.

Returns: undefined | string


hasError

get hasError(): boolean

Defined in fieldState.ts:76

If the state contains error.

Returns: boolean


validated

get validated(): boolean

Defined in fieldState.ts:84

If the validation has been done. It does not means validation passed.

Returns: boolean


validating

get validating(): boolean

Defined in fieldState.ts:57

If the state is doing a validation.

Returns: boolean

Methods

disableValidationWhen

disableValidationWhen(predict: function): this

Defined in fieldState.ts:199

Configure when to disable validation.

Parameters:

predict: function

▸ (): boolean

Returns: this


dispose

dispose(): void

Inherited from Disposable.dispose

Defined in disposable.ts:23

Do dispose by calling all disposer functions.

Returns: void


onChange

onChange(value: TValue): void

Defined in fieldState.ts:119

Set _value on change event.

Parameters:

Name Type
value TValue

Returns: void


reset

reset(): void

Defined in fieldState.ts:134

Reset to initial status.

Returns: void


set

set(value: TValue): void

Defined in fieldState.ts:126

Set value (& _value) synchronously.

Parameters:

Name Type
value TValue

Returns: void


setError

setError(error: ValidationResponse): void

Defined in fieldState.ts:91

Set error info.

Parameters:

Name Type
error ValidationResponse

Returns: void


validate

validate(): Promise‹object | object›

Implementation of ComposibleValidatable

Defined in fieldState.ts:171

Fire a validation behavior.

Returns: Promise‹object | object›


validators

validators(...validators: Validator‹TValue›[]): this

Defined in fieldState.ts:103

Add validator function.

Parameters:

Name Type
...validators Validator‹TValue›[]

Returns: this