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

apply validation rules to each item in a Slice #3

Open
woodsaj opened this issue Sep 9, 2015 · 1 comment
Open

apply validation rules to each item in a Slice #3

woodsaj opened this issue Sep 9, 2015 · 1 comment

Comments

@woodsaj
Copy link
Contributor

woodsaj commented Sep 9, 2015

I would like to be able to apply validation rules to each item in a slice.

eg

type MyStruct struct {
   Id int
   MyNumbers []int `json:"my_numbers" binding:"range(1, 10)"`
}

The following should then fail validation as one of the items in the list is outside of the range.

{
  "id": 1,
  "my_numbers": [1,2,3,4,100]
}

This would require replacing MinSize and MaxSize from being applied to slice lengths, so that rules can instead be used for length of each item in a slice of strings. New rules specific to slice length would then need to be introduced.

@woodsaj
Copy link
Contributor Author

woodsaj commented Sep 9, 2015

https://github.com/macaron-contrib/binding/pull/4 has most of the changes needed to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant