Often it happens that you use a specific input or framework, so the default getter, setter and extractor for the event won't cut it. No worries: formhero got you covered!
This is the base state of the form. Also the typescript types are inhered by this.
###### Example
```javascript
const initial = {
username: 'defaultValue',
password: '',
rememberMe: true,
}
```
### Validators
A validator is an object that taked in either a `RegExp` or a `Function` (can be async). Optionally you can pass a message string that will be displayed instead of the default one.
###### Example: Regular Expression
```javascript
const validators = {
// Only contains letters.
// This could also be a (also async) function that returns a boolean.
Sometimes it's practical to have some different default values when using for example react-native or some other framework where the default `value`, `onChange` and `(e)=> e.target.value` do not apply.
###### Example: React Native (Method 1 - Global options)
[Check the Expo Snack for a live preview](https://snack.expo.io/@cupcakearmy/useform)
The `auto` object is used to bind the form state to the input.
###### Example: Simple
```javascript
const { auto } = useForm()
<input{...auto('username')}/>
```
###### Example: With custom options
All are optional.
```javascript
const { auto } = useForm()
<input{...auto('username',{
getter: 'onChage',
setter: 'value',
extractor: (e) => e.target.value
})} />
```
## Form
This is the form state that you can use when submitting the data
###### Example
```javascript
const { form } = useForm(...);
// ...
<formonSubmit={()=> console.log(form)}>
// ...
</form>
```
## Errors
This object contains the error messages if a field is not valid.
The error message can be specified by you, otherwise it will return `Error in ${field}`
###### Example
```javascript
const { errors } = useForm(...)
//...
{errors.username}
{errors.password}
```
###### isValid
`isValid` is a little simple helper that checks whether the `error` object is clear or if there are errors left.
## Update
The `update` function allows you to manually change and assign the state of the form. This can be usefull when you want to reset a field or the whole form. The input must have the same type as the initial state.