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

ContainsOnly validator #149

Closed
sloria opened this Issue Feb 17, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@sloria
Member

sloria commented Feb 17, 2015

From the thread in #135 (comment) (trimmed for brevity):

@philtay

Do you want a ContainsOnly validator? [...] It's the natural extension of OneOf to sequences. Colander implements it using the set's method issubset, but I want to make it more generic (i.e. without the requirement of hashable items). I need it especially in combination with the List field.

Further comments

@davidism

Rather than separate validators for OneOf and ContainsOnly, one Choices validator that takes a multi=True argument seems more straightforward.

@philtay

My idea is to subclass OneOf and override call. I prefer to not put too much logic in a single validator. They must be very robust and thus very easy to debug. Anyway your idea is certainly doable.

@sloria sloria added the enhancement label Feb 17, 2015

@sloria sloria added this to the 2.0-a milestone Feb 17, 2015

@philtay

This comment has been minimized.

Contributor

philtay commented Feb 17, 2015

@sloria what approach do you prefer?

@sloria

This comment has been minimized.

Member

sloria commented Feb 17, 2015

I agree with @philtay on having separate validators. The meaning of ContainsOnly seems clearer than Choices(multi=True) and better to keep the validators small and focused.

@philtay philtay referenced this issue Feb 22, 2015

Merged

ContainsOnly #159

@sloria

This comment has been minimized.

Member

sloria commented Feb 22, 2015

Closed by #159

@sloria sloria closed this Feb 22, 2015

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