@shopify/react-form-state
Advanced tools
Comparing version 0.10.5 to 0.10.6
@@ -315,2 +315,22 @@ # Building forms with FormState | ||
To run multiple functions on an inner field of a nested field you can use [validateNested](validators.md#validatenested). | ||
```typescript | ||
validators={{ | ||
person: validateNested({ | ||
age: [ | ||
(input) => { | ||
if (input < 16) { | ||
return 'too young'; | ||
} | ||
}, | ||
(input) => { | ||
if (input > 200) { | ||
return 'too old'; | ||
} | ||
}, | ||
] | ||
}) | ||
``` | ||
`<FormState />` generates handlers that follow the [Polaris form validation guidelines](https://polaris.shopify.com/patterns/error-messages#section-form-validation). When you blur an input, or when you change it and it already has an error, any defined validators for that field will be invoked. | ||
@@ -317,0 +337,0 @@ |
@@ -212,3 +212,6 @@ # Validators | ||
firstVariant: validateNested({ | ||
price: validators.numericString('variant price should be a number'), | ||
price: [ | ||
validators.numericString('variant price should be a number'), | ||
nextValidator('message') | ||
], | ||
sku: validators.lengthLessthan(3, 'variant SKU must be shorter than 3 characters'); | ||
@@ -215,0 +218,0 @@ }); |
{ | ||
"name": "@shopify/react-form-state", | ||
"version": "0.10.5", | ||
"version": "0.10.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Manage react forms tersely and type-safe with no magic.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
189191