class CrSerializer::Assertions::ChoiceAssertion(ActualValueType)
- CrSerializer::Assertions::ChoiceAssertion(ActualValueType)
- CrSerializer::Assertions::Assertion
- Reference
- Object
Overview
Validates a property is a valid choice
Usable on all data types
Optional annotation fields:
- min_matches :
Int32
- Must select at lestmin_matches
to be valid - min_message :
String
- Message to display if too few choices are selected - max_matches :
Int32
- Must select at mostmax_matches
to be valid - max_message :
String
- Message to display if too many choices are selected - multiple_message :
String
- Message to display if one or more values in the#actual
value is not inchoices
@[Assert::Choice(choices: [10_i64, 50_i64, 100_i64])]
property level : Int64
NOTE choices array must be of same type as property
Defined in:
CrSerializer/assertions/choice.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
ameba:disable Metrics/CyclomaticComplexity
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 : ActualValueType, choices : Array(ALLDATATYPES), min_matches : Int32 | Nil = nil, max_matches : Int32 | Nil = nil, min_message : String | Nil = nil, max_message : String | Nil = nil, multiple_message : String | Nil = nil)
#