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

support validation of slices of structs #4

Merged
merged 1 commit into from
Sep 11, 2015

Conversation

woodsaj
Copy link
Contributor

@woodsaj woodsaj commented Sep 9, 2015

No description provided.

@unknwon
Copy link
Contributor

unknwon commented Sep 9, 2015

Thanks your PR!

I have a question here:

So how do you apply validation on slice itself now? Let's say, MinSize of a slice?

@woodsaj
Copy link
Contributor Author

woodsaj commented Sep 9, 2015

Validating the structs within a slice is just an additional step of the validation process flow.
The existing logic, where the slice itself is subjected to validation is still in place. This is validated with the Unit Tests.

However, as per https://github.com/macaron-contrib/binding/issues/3, it would be great if we could create new validation rules for slices, SliceSize, SliceMinSize, SliceMaxSize, so that we could then apply the validation rules to the items in a slice. This would however, cause problems for users already relying on Size, MinSize and MaxSize for validating the number of items in a slice.

@unknwon
Copy link
Contributor

unknwon commented Sep 9, 2015

However, as per #3, it would be great if we could create new validation rules for slices, SliceSize, SliceMinSize, SliceMaxSize, so that we could then apply the validation rules to the items in a slice. This would however, cause problems for users already relying on Size, MinSize and MaxSize for validating the number of items in a slice.

Yes, what about using Item.. prefix for rules that validate slice items?

@woodsaj
Copy link
Contributor Author

woodsaj commented Sep 9, 2015

I guess that could be made to work.

To be clear, though this PR addresses https://github.com/macaron-contrib/binding/issues/2

Additional work would be needed to address https://github.com/macaron-contrib/binding/issues/3

@unknwon
Copy link
Contributor

unknwon commented Sep 9, 2015

I guess that could be made to work.

To be clear, though this PR addresses #2

Additional work would be needed to address #3

Thanks your clarification!

@unknwon unknwon changed the title support validation of slices of structs. support validation of slices of structs Sep 9, 2015
@unknwon
Copy link
Contributor

unknwon commented Sep 11, 2015

Merging... thanks again!

unknwon added a commit that referenced this pull request Sep 11, 2015
support validation of slices of structs
@unknwon unknwon merged commit 1935a99 into go-macaron:master Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants