Skip to content

reusable combinable composite field validators for mongoengine models

License

Notifications You must be signed in to change notification settings

phantie/mongoengine-field-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

reusable combinable composite field validators for mongoengine models

Topics

Resources

License

Stars

Watchers

Forks

Languages