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

Proposal for a contains rule #358

Closed
funkyfuture opened this issue Jan 25, 2018 · 1 comment
Closed

Proposal for a contains rule #358

funkyfuture opened this issue Jan 25, 2018 · 1 comment

Comments

@funkyfuture
Copy link
Member

funkyfuture commented Jan 25, 2018

while we were looking on a deceased project to test json-apis we noticed one validation rule it has that Cerberus doesn't have: contains. quiet obviously, it would test whether an object that implements a __contains__ method contains the constraining values.

# schema
foo:
  contains: "1"

# another schema
foo:
  contains: ["1", "2"]

# valid doc
foo:
  - "1"
  - "2"
  - "3"

# invalid doc
foo:
  - "4"
  - "5"
  - "6"

strings are not considered as a container object, so this isn't suitable to test substrings, there's regex for that.

or am i overlooking the possibilty to do such tests already?

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 21, 2018
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 21, 2018
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue May 31, 2018
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue May 31, 2018
@funkyfuture
Copy link
Member Author

Implemented in #387.

nicolaiarocci pushed a commit that referenced this issue Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant