var validator = new ObjectValidator
validator.add new EmailField("email")
assert not validator.validate("""{ "email": "" }""")
assert not validator.validate("""{ "email": "foo" }""")
assert validator.validate("""{ "email": "alexandre@moz-code.org" }""")
assert validator.validate("""{ "email": "a+b@c.d" }""")
popcorn :: EmailField :: defaultinit
popcorn $ EmailField :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
popcorn :: RegexField :: defaultinit
popcorn :: RequiredField :: defaultinit
popcorn :: EmailField :: defaultinit
core :: Object :: defaultinit
popcorn :: FieldValidator :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).popcorn :: RequiredField :: required=
Is this field required?popcorn :: FieldValidator :: validate_field
Validatefield
in obj
# Check if a field is a valid email
#
# ~~~
# var validator = new ObjectValidator
# validator.add new EmailField("email")
# assert not validator.validate("""{ "email": "" }""")
# assert not validator.validate("""{ "email": "foo" }""")
# assert validator.validate("""{ "email": "alexandre@moz-code.org" }""")
# assert validator.validate("""{ "email": "a+b@c.d" }""")
# ~~~
class EmailField
super RegexField
autoinit field, required
redef var re = "(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9.-]+$)".to_re
end
lib/popcorn/pop_validation.nit:711,1--727,3