question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating nested array fields

See original GitHub issue

currently 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:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
brauliodiezcommented, Jul 27, 2020

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.

1reaction
jgouxcommented, Mar 9, 2020

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found