class CrSerializer::Assertions::SizeAssertion(ActualValueType)
- CrSerializer::Assertions::SizeAssertion(ActualValueType)
- CrSerializer::Assertions::Assertion
- Reference
- Object
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)
Defined in:
CrSerializer/assertions/size.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
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 class CrSerializer::Assertions::Assertion
Returns true if the provided property passes the assertion, otherwise false.
TODO make this abstract once this issue is resolved.