class CrSerializer::Assertions::UrlAssertion(ActualValueType)
- CrSerializer::Assertions::UrlAssertion(ActualValueType)
- CrSerializer::Assertions::Assertion
- Reference
- Object
Overview
Validates a string is a properly formatted URL.
Usable on only String
properties
Optional annotation fields:
- protocols :
Array(String)
- The protocols considered to be valid for the URL. Default["http","https"]
. - relative_protocol :
Bool
- If true, the protocol is considered optional when validating the URL. Defaultfalse
.
@[Assert::Url]
property image_url : String
NOTE Nil values are considered valid
Defined in:
CrSerializer/assertions/url.crConstructors
Instance Method Summary
-
#actual
The current value of the property
-
#error_message : String
The message that will be shown if the assertion is not valid
-
#valid? : Bool
Returns true if the provided property passes the assertion, otherwise false.
Instance methods inherited from class CrSerializer::Assertions::Assertion
error_message : String
error_message,
field : String
field,
valid? : Bool
valid?
Constructor methods inherited from class CrSerializer::Assertions::Assertion
new(field : String, message : String | Nil)
new
Instance methods inherited from class Object
to_json(io : IO, groups : Array(String), expand : Array(String))to_json(groups : Array(String) = ["default"], expand : Array(String) = [] of String) : String to_json, to_pretty_json(indent : String = " ", groups : Array(String) = ["default"], expand : Array(String) = [] of String)
to_pretty_json(io : IO, groups : Array(String), expand : Array(String), indent : String = " ") to_pretty_json, to_yaml(groups : Array(String) = ["default"], expand : Array(String) = [] of String) : String to_yaml
Constructor Detail
def self.new(field : String, message : String | Nil, actual : String | Nil, protocols : Array(String) = ["http", "https"] of ::String, relative_protocol : Bool = false)
#
Instance Method Detail
def valid? : Bool
#
Description copied from class CrSerializer::Assertions::Assertion
Returns true if the provided property passes the assertion, otherwise false.
TODO make this abstract once this issue is resolved.