import falcon
from cerberus import Validator


def validate_user_create(req, res, resource, params):
    schema = {
        'email': {
            'type': 'string',
            'regex': '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$',
            'required': True
        },
        'password': {
            'type': 'string',
            'minlength': 8,
            'required': True
        }
    }

    v = Validator(schema)
    if not v.validate(req.context['data']):
        raise falcon.HTTPBadRequest('Bad request', v.errors)


def validate_user_auth(req, res, resource, params):
    schema = {
        'email': {
            'type': 'string',
            'regex': '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$',
            'required': True
        },
        'password': {
            'type': 'string',
            'required': True
        }
    }

    v = Validator(schema)
    if not v.validate(req.context['data']):
        raise falcon.HTTPBadRequest('Bad request', v.errors)

@@ -968,28 +968,409 @@
 st('Bad request', v.errors)%0A
+%0A%0Adef validate_request_password_reset(req, res, resource, params):%0A    schema = %7B%0A        'email': %7B%0A            'type': 'string',%0A            'regex': '%5E%5Ba-zA-Z0-9_.+-%5D+@%5Ba-zA-Z0-9-%5D+%5C.%5Ba-zA-Z0-9-.%5D+$',%0A            'required': True%0A        %7D%0A    %7D%0A%0A    v = Validator(schema)%0A    if not v.validate(req.context%5B'data'%5D):%0A        raise falcon.HTTPBadRequest('Bad request', v.errors)%0A

Validate pw reset request