Skip to content

Latest commit

 

History

History
212 lines (125 loc) · 5.68 KB

definitions.md

File metadata and controls

212 lines (125 loc) · 5.68 KB

useForm Type Definitions

Table of contents

ErrorType

Ƭ Object

Type declaration

Param Type
hasError boolean
message string

Defined at index.ts:209


ErrorsType

Ƭ Object

Index signature

▪ [key: string]: ErrorType

key: input field name

Defined at index.ts:214


FormInputType

Ƭ Object

Type declaration

Param Type
required boolean
validator? ValidatorFuncType
value ValueType

? optional params

Defined at index.ts:189


FormModelType

Ƭ Object

Index signature

▪ [key: string]: FormInputType

key: input field name

Defined at index.ts:185


IsDirtyType

Ƭ Object

Index signature

▪ [key: string]: boolean

key: input field name

Defined at index.ts:195


IsRequiredType

Ƭ Object

Index signature

▪ [key: string]: boolean

key: input field name

Defined at index.ts:199


ValidatorFuncType

Ƭ (value: ValueType , values?: ValuesType) => string

Parameters
Param Type Description
value ValueType current value of input field
values? ValuesType values state object to compare for validation

? optional params

Returns

string: custom error message returned from the validator function, or an empty string for no error.

Defined at index.ts:183


ValueType

Ƭ string

Defined at index.ts:203


ValuesType

Ƭ Object

Index signature

▪ [key: string]: ValueType

key: input field name

Defined at index.ts:205


HandleOnChangeType

Ƭ (event: ChangeEvent<HTMLInputElement>) => void

Parameters
Param Type
event ChangeEvent<HTMLInputElement>
Returns void

! returns nothing directly to the end user as it manages the controlled form values and _IsDirty states.

Defined at index.ts:180


HandleOnSubmitType

Ƭ (event: FormEvent<HTMLFormElement>) => void

Parameters
Param Type
event FormEvent<HTMLFormElement>
Returns void

! when the form has been validated, enabled and submitted, this callback function triggers another function set by the user.

Defined at index.ts:181


useFormType

Ƭ Object

Type declaration

Param Type Description
values ValuesType returns form values state object
errors ErrorsType returns form errors state object
handleOnChange HandleOnChangeType binds to a HTMLInputElement: change event
handleOnSubmit HandleOnSubmitType binds to a HTMLFormElement: submit event
isDisabled boolean returns true / false when the form is valid / invalid
isSubmitted boolean returns true when the form was submitted without errors
formModel FormModelType initial form model with optional validation function
formSubmitCallback () => void function to run after form validation and submission

! useForm takes two params: formModel and formSubmitCallback and returns the rest.

Defined at index.ts:171

Docs created using:

typedoc and typedoc-plugin-markdown