Skip to content

Latest commit

 

History

History
98 lines (51 loc) · 2.84 KB

useValidator.md

File metadata and controls

98 lines (51 loc) · 2.84 KB

realueDocs


realue / useValidator

Function: useValidator()

useValidator(props, onValidate)

useValidator<T, N, E>(props, onValidate?): PromiseState<E | undefined>

Validates the provided value property using the onValidate asynchronous callback function. This function returns a promise state object that tracks the status of the validation process.

The onValidate callback function is expected to return a value or a promise that resolves with one of the following:

  • An error value indicating that validation has failed.
  • undefined if the validation succeeds without errors.

Type Parameters

T

N extends string

E extends ErrorReportValue

Parameters

props: NevoProps<T, E>

Properties according to the NEVO pattern.

onValidate?: ValueValidator<T, E>

Synchronous or asynchronous value validator.

Returns

PromiseState<E | undefined>

The promise state object.

Defined in

lib/hooks/useValidator.ts:28

useValidator(props, onValidate)

useValidator<T, N, E>(props, onValidate?): PromiseState<E | undefined>

Type Parameters

T extends object

N extends string

E extends ErrorReportObject<T>

Parameters

props: NevoProps<T, E>

onValidate?: ValueValidator<T, E>

Returns

PromiseState<E | undefined>

Defined in

lib/hooks/useValidator.ts:32

useValidator(props, onValidate)

useValidator<T, N, E>(props, onValidate?): PromiseState<E | undefined>

Type Parameters

T extends unknown[]

N extends string

E extends ErrorReportArray<T>

Parameters

props: NevoProps<T, E>

onValidate?: ValueValidator<T, E>

Returns

PromiseState<E | undefined>

Defined in

lib/hooks/useValidator.ts:40