I want to create array of fields but to validate array elements customly
See original GitHub issueHi guys,
I have a problem validating array of fields on my own, what I mean is that I have an array of fields where I don’t want to validate specific fields on index
const schema = Yup.object().shape({
inviteUsers: Yup.array().of(Yup.object().shape({
firstName: Yup.string().required(),
lastName: Yup.string().required(),
email: Yup.string().email().required(),
userType: Yup.string().required(),
})),
});
so, for example, I don’t what to validate the last element of the array of inviteUsers
, how is it possible? I checked custom addMethod
function but I didn’t find any viable solution
thank you in advance
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Validating Arrays And passing field values between each other
I am attempting to validate an array from my form inputs. I will need to pass one of my fields' value to an...
Read more >Validating arrays and nested values in Laravel - LogRocket Blog
In our form, we have fields for the item name, the SKU, and the price. We need to validate these items when a...
Read more >How To: Validate an array of form fields with Laravel – Eric L ...
Going off the top of my head I'd think you would want to check the Input for “items” then loop Input::get('items') in your...
Read more >How to validate array fields? - Laracasts
So I have two fields that looks like this. ... Why is it so hard with array form element ? ... Custom validation...
Read more >5. Working with Arrays and Loops - JavaScript Cookbook [Book]
Not all array elements have to be defined when created. For instance, if you create an array literal, you can use commas to...
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
you could also use
.compact()
if you can identify the last entry based on a fixed set of criteria. fyi,.validate()
will exclude that entry from the returned value, but the original input will remain intact.example:
@knicola I think I can use the last one, thanks for your time