You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -83,13 +81,13 @@ Hook that keeps on form field's data.
83
81
| ---- | ---- | ---- | ----------- |
84
82
| initialValue |_any_| yes | Field's initial value |
85
83
| validationFn |_(any) => boolean or Promise<boolean>_| yes | Function for validating the field's value |
86
-
| config |_{<br> receiveEvent: boolean,<br> reversed: boolean<br> ignoreDirtiness: boolean<br>}_| no | Additional hook configuration.<br><br><ul><li>`receiveEvent` inidicates whether `onChange` callback will receive whole event or just target's value</li><li>`reversed` indicates whether reversed error logic should be applied (error being `false` when present, instead of `true`)</li><li>`ignoreDirtiness` indicating whether field's dirtiness should be ignored (by default, field is validate on blur, but only if field is dirty ie. if its value has been changed)</li></ul>|
84
+
| config |_{<br> receiveEvent?: boolean,<br> reversed?: boolean<br> ignoreDirtiness?: boolean<br>}_| no | Additional hook configuration.<br><br><ul><li>`receiveEvent` inidicates whether `onChange` callback will receive whole event or just target's value</li><li>`reversed` indicates whether reversed error logic should be applied (error being `false` when present, instead of `true`)</li><li>`ignoreDirtiness` indicating whether field's dirtiness should be ignored (by default, field is validate on blur, but only if field is dirty ie. if its value has been changed)</li></ul>|
87
85
88
86
#### Returns
89
87
90
88
| Type <divstyle="width: 200px"></div> | Description |
91
89
|---- | ----------- |
92
-
| _{<br> value: any,<br> error: boolean<br> onChange: (any, config) => void<br> onBlur: (event, config) => void<br> setValue: (value: any) => void<br> validate: (any, config) => boolean or Promise<boolean><br> reset: () => void,<br> props: {<br> value: any,<br> onChange: (any, config) => void<br> onBlur: (event, config) => void<br> }<br>}_ | Object with field's data and callbacks.<br><br><ul><li>`value` - field's current value</li><li>`error` - is error present flag (`true` if value was validated and didn't pass validation, `false` otherwise)</li><li>`onChange` - callback for change event (change's the value and validates it if previous value wasn't correct)</li><li>`onBlur` - callback for blur event (validates the value)</li><li>`validate` - function for validating field's value</li><li>`reset` - function for resetting field's data</li><li>`props` - set of props that can be spread on standard input elements (same as props in root object, just grouped for better DX)</li></ul><br/>`onChange`, `onBlur` and `validate` functions accept config as last parameter - this will override config from `useValidation` if provided. |
90
+
| _{<br> value: any,<br> error: boolean<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> setValue: (value: any) => void<br> validate: (any, config?) => boolean or Promise<boolean><br> reset: () => void,<br> props: {<br> value: any,<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> }<br>}_ | Object with field's data and callbacks.<br><br><ul><li>`value` - field's current value</li><li>`error` - is error present flag (`true` if value was validated and didn't pass validation, `false` otherwise)</li><li>`onChange` - callback for change event (changes the value and validates it if previous value wasn't correct)</li><li>`onBlur` - callback for blur event (validates the value)</li><li>`setValue` - function for setting the internal value (does not validate the input, enabling support for async data loading)</li><li>`validate` - function for validating field's value</li><li>`reset` - function for resetting field's data</li><li>`props` - set of props that can be spread on standard input elements (same as props in root object, just grouped for better DX)</li></ul><br/>`onChange`, `onBlur` and `validate` functions accept config as last parameter - this will override config from `useValidation` if provided. |
93
91
94
92
#### Usage example
95
93
@@ -221,7 +219,7 @@ Util function for handling the form submit. Form's fields are first validated. I
221
219
| Name | Type <divstyle="width: 200px"></div> | Required | Description |
222
220
| ---- | ---- | ---- | ----------- |
223
221
| fields |_{<br/> key: {<br> value: any<br> validate: (any) => boolean<br> },<br/> ...<br/>}_| yes | Form field's data (each field must have `value` and `validate` properties - other properties are not important) |
| onSubmit |_(any) => object or void_| yes | On submit callback |
225
223
226
224
#### Returns
227
225
@@ -334,6 +332,10 @@ Is non-empty array validation. Value of the field with this validation function
334
332
335
333
Is valid email validation. Value od the field with this validation function will be correct if it is non-empty string with valid email address.
336
334
335
+
### `isValidIpAddress(value)`
336
+
337
+
Is valid IP address validation. Value od the field with this validation function will be correct if it is a non-empty string with valid IPv4 or IPv6 address.
338
+
337
339
## Future plans
338
340
339
341
We noticed that there are few things which could be added to our package in order to make it more flexible and easy to use. Here is what you can expect in the future:
0 commit comments