Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 907 Bytes

README.rst

File metadata and controls

35 lines (30 loc) · 907 Bytes
class Validation:
    nickname = (
        StringTypeValidator &
        LengthValidator(21) &
        AlphaNumericValidator
    )

    name = (
        StringTypeValidator &
        LengthValidator(24) &
        NoNumbersValidator &
        TitledValidator &
        AlphaNumericValidator
    )

    city = (
        StringTypeValidator &
        LengthValidator(24) &
        NoNumbersValidator &
        (TitledValidator | CapitalizedValidator) &
        AlphaNumericValidator
    )

class User(Document):
    nickname = StringField(validation=Validation.nickname)
    name = StringField(validation=Validation.name)
    city = StringField(required=False, validation=Validation.city)

User(
    nickname='phantie',
    name='Alex',
    city='Odessa'
        ).validate()