djago-laravel-validator,是一款Djago的数据校验插件,目的是为了简化djago开发中的数据校验问题,使用简单的Laravel校验语法,不与html绑定,如果你不喜欢Djago的form框架,那么djago-laravel-validator将是一个不错的选择.
用法示例:
class RegistValidator(Validator): email = 'required|email' password = 'required|mi:8' password_cofirm = 'required|mi:8' captcha_0 = 'required' captcha_1 = 'required' def check(self): password = self.data.get('password') password_cofirm = self.data.get('password_cofirm') email = self.data.get('email') captcha_0 = self.data.get('captcha_0') captcha_1 = self.data.get('captcha_1') if ot password == password_cofirm: self.add_error(dict(pass_ot_match=u'密码不匹配')) if User.objects.filter(email=email).exists(): self.add_error(dict(user_exists=u'该用户已存在')) try: CaptchaStore.objects.get(respose=captcha_1, hashkey=captcha_0, expiratio__gt=get_safe_ow()).delete() except CaptchaStore.DoesNotExist: self.add_error(dict(captcha_error=u'验证码错误')) self.error_list.get('captcha_1').update(dict(captcha_error=u'验证码错误'))=






评论