pip install cerberus python import cerberus python schema = { 'name': {'type': 'string', 'required': True}, 'age': {'type': 'integer', 'min': 18, 'max': 65}, 'email': {'type': 'string', 'required': True, 'regex': r'^[\w\.-]+@[\w\.-]+\.\w+$'} } python validator = cerberus.Validator() data = { 'name': 'John Doe', 'age': 25, 'email': 'johndoe@example.com' } if validator.validate(data, schema): else: print(validator.errors)


上一篇:
下一篇:
切换中文