Matched against the following regular expression:
^(http|https):\/\/[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)+([a-zA-Z0-9\-\.,@?^=%&:/~\+#]*[a-zA-Z0-9\-\@?^=%&/~\+#])?
You should redefine the base regular expression re
with your own.
var validator = new ObjectValidator
validator.add new URLField("url")
assert not validator.validate("""{ "url": "" }""")
assert not validator.validate("""{ "url": "foo" }""")
assert not validator.validate("""{ "url": "http://foo" }""")
assert validator.validate("""{ "url": "http://nitlanguage.org" }""")
assert validator.validate("""{ "url": "http://nitlanguage.org/foo" }""")
assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q" }""")
assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q&a" }""")
assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q&a=1" }""")
popcorn :: URLField :: defaultinit
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
popcorn :: RegexField :: defaultinit
popcorn :: RequiredField :: defaultinit
popcorn :: URLField :: 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 URL
#
# Matched against the following regular expression:
# ~~~raw
# ^(http|https):\/\/[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)+([a-zA-Z0-9\-\.,@?^=%&:/~\+#]*[a-zA-Z0-9\-\@?^=%&/~\+#])?
# ~~~
# You should redefine the base regular expression `re` with your own.
#
# ~~~
# var validator = new ObjectValidator
# validator.add new URLField("url")
# assert not validator.validate("""{ "url": "" }""")
# assert not validator.validate("""{ "url": "foo" }""")
# assert not validator.validate("""{ "url": "http://foo" }""")
# assert validator.validate("""{ "url": "http://nitlanguage.org" }""")
# assert validator.validate("""{ "url": "http://nitlanguage.org/foo" }""")
# assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q" }""")
# assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q&a" }""")
# assert validator.validate("""{ "url": "http://nitlanguage.org/foo?q&a=1" }""")
# ~~~
class URLField
super RegexField
autoinit field, required
redef var re = "^(http|https):\\/\\/[a-zA-Z0-9\\-_]+(\\.[a-zA-Z0-9\\-_]+)+([a-zA-Z0-9\\-\\.,@?^=%&:/~\\+#]*[a-zA-Z0-9\\-\\@?^=%&/~\\+#])?".to_re
end
lib/popcorn/pop_validation.nit:745,1--771,3