go-macaron / binding

Package binding is a middleware that provides request data binding and validation for Macaron.
Apache License 2.0
23 stars 17 forks source link

support validation of slices of structs #4

Closed woodsaj closed 9 years ago

unknwon commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

Merging... thanks again!