phonevalidator package¶
Subpackages¶
Submodules¶
phonevalidator.phonevalidator module¶
-
class
phonevalidator.phonevalidator.
Validator
(*args, **kwargs)[source]¶ Bases:
cerberus.cerberus.Validator
,phonevalidator.phonevalidator.ValidatorMixin
Extends cerberus.Validator and adds the phonenumber constraint to Cerburus validation’s.
Example: >>> from phonevalidator import Validator >>> schema = { ... 'phone': { ... 'type': 'phonenumber', ... 'formatPhoneNumber': True, ... 'phoneNumberFormat': 'NATIONAL', ... 'region': 'US' ... } ... } >>> doc = {'phone': '5135555555'} >>> v = Validator(schema) >>> v.validate(doc) True >>> v.document {'phone': '(513) 555-5555'} >>> doc = {'phone': 'gibberish'} >>> v.validate(doc) False
-
class
phonevalidator.phonevalidator.
ValidatorMixin
[source]¶ Bases:
object
A custom cerberus.Validator subclass adding the phonenumber constraint to Cerberus validation’s.
Example: >>> from phonevalidator import ValidatorMixin >>> from eve.io.mongo import Validator >>> from eve import Eve >>> class MyValidator(Validator, ValidatorMixin): ... ''' Custom validator that adds phone number ... validations. ... ''' ... pass >>> settings = {'DOMAIN': {}} >>> app = Eve(validator=MyValidator, settings=settings)
Module contents¶
-
class
phonevalidator.
Validator
(*args, **kwargs)[source]¶ Bases:
cerberus.cerberus.Validator
,phonevalidator.phonevalidator.ValidatorMixin
Extends cerberus.Validator and adds the phonenumber constraint to Cerburus validation’s.
Example: >>> from phonevalidator import Validator >>> schema = { ... 'phone': { ... 'type': 'phonenumber', ... 'formatPhoneNumber': True, ... 'phoneNumberFormat': 'NATIONAL', ... 'region': 'US' ... } ... } >>> doc = {'phone': '5135555555'} >>> v = Validator(schema) >>> v.validate(doc) True >>> v.document {'phone': '(513) 555-5555'} >>> doc = {'phone': 'gibberish'} >>> v.validate(doc) False
-
class
phonevalidator.
ValidatorMixin
[source]¶ Bases:
object
A custom cerberus.Validator subclass adding the phonenumber constraint to Cerberus validation’s.
Example: >>> from phonevalidator import ValidatorMixin >>> from eve.io.mongo import Validator >>> from eve import Eve >>> class MyValidator(Validator, ValidatorMixin): ... ''' Custom validator that adds phone number ... validations. ... ''' ... pass >>> settings = {'DOMAIN': {}} >>> app = Eve(validator=MyValidator, settings=settings)