Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to allow validation of array fields as reactive elements #80

Closed
davidecantini opened this issue Sep 22, 2015 · 3 comments
Closed

Fix to allow validation of array fields as reactive elements #80

davidecantini opened this issue Sep 22, 2015 · 3 comments

Comments

@davidecantini
Copy link

Hi,
Let's say we have a simple schema like this:

new SimpleSchema({
  emails: {
    type: [String],
    label: "Your Emails",
    regEx: SimpleSchema.RegEx.Email,
    minCount: 1,
    min: 5
  }
})

and the requirements would be:

  • validate each array field (email in this case) and the array to contain the required elements (the approach suggested in the comments to issue 48 would not meet these requirement, since the single fields would not be reactive-elements)
  • the UI must enable the user to add/remove email fields through the UI (this is strictly related to issue 73)

Can you please provide some indications/best practices on how that could be achieved? This may be about adding examples to the docs but possibly adding some features or bug fixing.

Thanks in advance for your attention.

@davidecantini davidecantini changed the title How to validate both an array and each of its items? How to deal with array fields? Sep 25, 2015
@davidecantini
Copy link
Author

Update:
For the points mentioned above, I was eventually able to add support to meet the requirements and get an approach like the user's application linked in the package docs to work properly.
However, that required some extra code at app level that could be completely avoided if the package could have a feature (or fix) like the one described in issue 73:

"There may be some issue with it collecting data from individual elements and not handling when they are removed. Perhaps something needs to be added to handle this in an onDestroyed hook in the form elements."

@jonjamz Hopefully that, or any equivalent feature that you think can achieve the same goal (i.e. make sure that only the values of elements that have a .reactive-element class at the time of submit action are included in the valid values) can be introduced in the next versions.

With that in place, I think the package is great and would definitely star it.

Thanks in advance.

@davidecantini davidecantini changed the title How to deal with array fields? Fix to allow validation of array fields as reactive elements Sep 29, 2015
@davidecantini
Copy link
Author

@jonjamz Once you release version 2.0 with the modifications mentioned in issue 84 you can close this issue, which will get addressed by the new release. Thank you.

@jonjamz
Copy link
Owner

jonjamz commented Dec 23, 2015

Thanks!

@jonjamz jonjamz closed this as completed Dec 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants