def assert_email_valid(value, kw={}): validator = IsEmail(**kw) el = email(value) print el print validator.validate(el, None) assert validator.validate(el, None) assert not el.errors
def validate(self, element, state): if element.properties.get("not_empty_error"): self.fail = fl.validation.base.N_(element.properties["not_empty_error"]) else: self.fail = fl.validation.base.N_(u'One or more email addresses are not valid.') is_email_validator = IsEmail() if not element.optional and not element: return self.note_error(element, state, 'fail') for e in element: if e.value and not is_email_validator.validate(e, None): return self.note_error(element, state, 'fail') return True
class SignupForm(Form): username = String.using(label='Username', validators=[Present()]) password = String.using(label='Password', validators=[ Present(), LengthBetween(5, 25), ValuesEqual('.', '../confirmPassword') ]) confirmPassword = String.using(label='Confirm Password', validators=[Present()]) email = String.using(label='Email', validators=[Present(), IsEmail()]) firstname = String.using(label='First Name', validators=[Present()]) lastname = String.using(label='Last Name', validators=[Present()]) output_schema = [ 'username', 'password', 'confirmPassword', 'email', 'firstname', 'lastname' ]
def assert_email_valid(value, kw={}): validator = IsEmail(**kw) el = email(value) assert validator.validate(el, None) assert not el.errors
if not self.validnamespace(meta.get(NAMESPACE)): return self.note_error(element, state, 'invalid_namespace_msg') if state[FQNAME].field == ITEMID: if not self.validitemid(meta.get(ITEMID, state[FQNAME].value)): return self.note_error(element, state, 'invalid_itemid_msg') return True JSON = OptionalMultilineText.with_properties( lang='en', dir='ltr').validated_by(ValidJSON()) URL = String.with_properties(widget=WIDGET_TEXT).validated_by(URLValidator()) Email = String.using(label=L_('E-Mail')).with_properties( widget=WIDGET_EMAIL, placeholder=L_("E-Mail address")).validated_by(IsEmail()) YourEmail = Email.with_properties(placeholder=L_("Your E-Mail address")) Password = Text.with_properties(widget=WIDGET_PASSWORD).using( label=L_('Password')) RequiredPassword = Password.validated_by(Present()) Checkbox = Boolean.with_properties(widget=WIDGET_CHECKBOX).using(optional=True, default=1) InlineCheckbox = Checkbox.with_properties(widget=WIDGET_INLINE_CHECKBOX) Select = Enum.with_properties(widget=WIDGET_SELECT)