jpmckinney / validictory

🎓 deprecated general purpose python data validator
Other
240 stars 57 forks source link

Support for 'allowedValues' property in array validation. #34

Closed nicolaiarocci closed 11 years ago

nicolaiarocci commented 12 years ago

Used instead of 'items', this property provides a list of values to match against a list. At least one value must be present. Allowed values include strings, numbers, lists and objects.

nicolaiarocci commented 12 years ago

Actually yes, you're right. I totally missed the enum functonality. One thing however that I don't like about enum is that it validates an empty array. In my use case (and i would assume in most cases where you provide a list of valid values) an empty list should not validate. I could patch validat_enum to raise a ValueError in case of empty array, what do you think?

nicolaiarocci commented 12 years ago

closed the pull request by mistake. Of course it will end up being closed soon enough :)

jamesturk commented 11 years ago

sorry, missed this being reopened somehow. if you don't want an empty array you can specify a min length of 1 as well as an enum for the allowed values