Skip to content

Proposal for a contains rule #358

Description

@funkyfuture

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions