diff --git a/form/README.md b/form/README.md new file mode 100644 index 0000000..fd9c2f6 --- /dev/null +++ b/form/README.md @@ -0,0 +1,132 @@ +# react-kit-form + +## Installation + +You can install react-kit-form by + +```bash + yarn add @bhoos/react-kit-form +``` + +## Usage/Example + +### A simple register user form . + +Let's say we want to add a signup form on our app. We have 3 input fields : username, contactNumber and contactNumberVerificationCode. + +```tsx +const App = () => { + + const formState = { + username:{ + parser: new TextParser().required(); + }, + contactNumber : { + parser: new IntegerParser().required().minLength(10).maxLength(10); + }, + contactNumberVerificationCode:{ + parser: new IntegerParser().required().minLength(6); + } + } + + const initialState = {}; + + const controller = useFormController(formState,initialState); + + const handleSignup = async () => { + const formValues = controller.getState(); + await fetch("https://fakeRegistration/registerUser",{ + method:'POST', + body:JSON.stringify(formValues), + headers:{ + 'Content-Type':'application/json' + } + }) + } + + return ( +
+ + + +