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

Comments

Projects
None yet
1 participant
@funkyfuture
Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2018

Implemented in #387.

@funkyfuture funkyfuture closed this Jun 2, 2018

nicolaiarocci added 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
You can’t perform that action at this time.