class CrSerializer::Assertions::EmailAssertion(ActualValueType)
Overview
Validates a string is a properly formatted email.
Usable on only String
properties
Optional annotation fields:
- mode :
EmailValidationMode
- Which validation pattern to use SeeEmailValidationMode
for more details. DefaultEmailValidationMode::LOOSE
.
@[Assert::Email]
property data : String
NOTE Nil values are considered valid
Included Modules
Defined in:
CrSerializer/assertions/email.crConstant Summary
-
HTML5 =
/^[a-zA-Z0-9.!\#$\%&\'*+\\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/
-
LOOSE =
/^.+\@\S+\.\S+$/
Constructors
Instance Method Summary
-
#valid? : Bool
Returns true if the provided property passes the assertion, otherwise false.
Instance methods inherited from module CrSerializer::Assertions::Assertion
actual
actual,
field : String
field,
valid? : Bool
valid?
Constructor methods inherited from module CrSerializer::Assertions::Assertion
new(field : String, message : String | Nil)
new
Instance methods inherited from class Object
to_json(io : IO, serialization_groups : Array(String), expand : Array(String))to_json(serialization_groups : Array(String) = ["default"], expand : Array(String) = [] of String) : String to_json, to_pretty_json(indent : String = " ", serialization_groups : Array(String) = ["default"], expand : Array(String) = [] of String)
to_pretty_json(io : IO, serialization_groups : Array(String), expand : Array(String), indent : String = " ") to_pretty_json, to_yaml(serialization_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, mode : EmailValidationMode = EmailValidationMode::LOOSE)
#
Instance Method Detail
def valid? : Bool
#
Description copied from module CrSerializer::Assertions::Assertion
Returns true if the provided property passes the assertion, otherwise false.