var validator = new ObjectValidator
validator.add new ISBNField("isbn")
assert not validator.validate("""{ "isbn": "foo" }""")
assert validator.validate("""{ "isbn": "ISBN 0-596-00681-0" }""")
popcorn :: ISBNField :: defaultinit
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
popcorn :: RegexField :: defaultinit
popcorn :: RequiredField :: defaultinit
popcorn :: ISBNField :: 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 ISBN
#
# ~~~
# var validator = new ObjectValidator
# validator.add new ISBNField("isbn")
# assert not validator.validate("""{ "isbn": "foo" }""")
# assert validator.validate("""{ "isbn": "ISBN 0-596-00681-0" }""")
# ~~~
class ISBNField
super RegexField
autoinit field, required
redef var re = "(^ISBN [0-9]-[0-9]\{3\}-[0-9]\{5\}-[0-9]?$)".to_re
end
lib/popcorn/pop_validation.nit:729,1--743,3