UNPKG

@nvidia1997/react-js-validator

Version:

#### This is react-wrapper for [js-validator](https://www.npmjs.com/package/@nvidia1997/js-validator). #### Please read its docs first!

34 lines (33 loc) 1.19 kB
import { Component, FormEvent, ReactNode } from "react"; import { Validator } from "@nvidia1997/js-validator"; interface IFormSubmitCallback { (e: FormEvent<HTMLFormElement>): any; } interface IFormSubmitReturnType { (e: FormEvent<HTMLFormElement>): boolean; } export interface IValidatorProvider { validator: Validator; createOnFormSubmitHandler: { (onSuccess?: IFormSubmitCallback, onError?: IFormSubmitCallback, preventDefault?: boolean): IFormSubmitReturnType; }; createOnValidationHandler: { (onSuccess: Function, onError: Function): Function; }; } interface IState { validator: Validator; } export declare class ValidatorProvider extends Component<{ children: ReactNode; }, IState> { updateState: (validatorId?: string | undefined) => void; state: { validator: Validator; }; isFunction: (callback: any) => boolean; createOnFormSubmitHandler: (onSuccess?: IFormSubmitCallback | undefined, onError?: IFormSubmitCallback | undefined, preventDefault?: boolean) => IFormSubmitReturnType; createOnValidationHandler: (onSuccess: Function, onError: Function) => Function; render(): JSX.Element; } export {};