Validating nested array fields
See original GitHub issuecurrently it’s not possible to validate nested array fields, for example:
const myRecord = {
translations: [
{title: 'my record title', hint: 'my record hint'},
{title: 'my record other title', hint: 'my record other hint'}
],
}
it’s not possible to apply validating to all of translations
indexes.
something like this should work:
const validationSchema = {
field: {
'translations': [
{
validator: Validators.maxLength.validator,
customArgs: { length: 5 }, // Valid translations for length lower than 5 item
}
],
'translations.*.title': [Validators.required.validator],
'translations.*.hint': [Validators.required.validator],
},
};
for more info please also see Lemoncode/fonk-formik#9
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Validating arrays and nested values in Laravel - LogRocket Blog
Luckily, Laravel provides a simple way to validate arrays and nested array input with the use of dot notation and the * character....
Read more >Nested array validation laravel - php - Stack Overflow
Validating array form input fields is much easier in Laravel 5.2. For example, to validate that each e-mail in a given array input...
Read more >Validating Nested Array of Objects - Laracasts
I know how to validate a nested array. but this has array of objects that each one needed to be validated. how can...
Read more >Validation - Laravel - The PHP Framework For Web Artisans
Validating Nested Array Input; Error Message Indexes & Positions ... If the incoming HTTP request contains "nested" field data, you may specify these...
Read more >Nested Objects and Arrays - VeeValidate
vee-validate supports nested objects and arrays by using field name syntax to indicate a field's path. This allows you to structure forms easily...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have news about this issue,
We have just released a Beta version including an ArrayValidator: https://github.com/Lemoncode/fonk/releases/tag/v1.4.0-beta.1
Example codesandbox: https://codesandbox.io/s/array-validator-formik-0c1dl?file=/form-validation.js
We are generating now more ellaborated examples.
Finally we have just created and ArrayValidator that is included in the main fonk library.
I was going to make an issue about it. Arrays are quite common when dealing with a lot of many to many relationships.
The ArrayValidator seems like a great idea!