class CrSerializer::Assertions::SizeAssertion(ActualValueType)
Overview
Validates a property's size is within a given Range
Usable only on types that have a #size
method, such as Array or String
Optional annotation fields:
- min_message :
String
- Message to display if the value is too small - max_message :
String
- Message to display if the value is too big
@[Assert::Size(range: 0_f64..100_f64)]
property age : Int64
NOTE Nil values are considered valid
NOTE range must be of type Range(Float64, Float64)
Included Modules
Defined in:
CrSerializer/assertions/size.crConstructors
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 : ActualValueType, range : Range(Float64, Float64), min_message : String | Nil = nil, max_message : String | Nil = nil)
#
Instance Method Detail
def valid? : Bool
#
Description copied from module CrSerializer::Assertions::Assertion
Returns true if the provided property passes the assertion, otherwise false.