Assert::Assertions::Valid(PropertyType)
Inherits Assert::Assertions::Assertion / Reference / Object
Validates child object(s) are valid; rendering the parent object invalid if any assertions on the child object(s) fail.
Example
class Foo
include Assert
def initialize(@some_val : Int32); end
@[Assert::EqualTo(value: 50)]
property some_val : Int32
end
class Example
include Assert
def initialize; end
@[Assert::EqualTo(value: 100)]
property int32 : Int32 = 100
@[Assert::Valid]
property foo : Foo = Foo.new(50)
@[Assert::Valid]
property foos : Array(Foo) = [Foo.new(50), Foo.new(50)]
end
Example.new.valid? # => true
Constructors
new(property_name : String, actual : PropertyType, message : String | Nil = nil, groups : Array(String) | Nil = nil)
SourceInstance methods
default_message_template
Returns the default #message_template to use if no message is provided.
message
The message to display if self is not valid.
NOTE: This method is defined automatically, and is just present for documentation purposes.