class Assert::Assertions::NotEqualTo(PropertyType)
Overview
Validates a property is not equal to value.
Example
class Example
include Assert
def initialize; end
@[Assert::NotEqualTo(value: 100)]
property int32 : Int32 = 50
@[Assert::NotEqualTo(value: 0.0001)]
property float : Float64 = 0.00001
@[Assert::NotEqualTo(value: "X")]
property string : String = "Y"
@[Assert::NotEqualTo(value: max_value)]
property getter_property : UInt8 = 255_u8
def max_value : UInt8
250_u8
end
end
Example.new.valid? # => true
NOTE value can be a hard-coded value like 10
, the name of another property, a constant, or the name of a method.
NOTE The type of value and actual must match.
NOTE PropertyType
can be anything that defines a #!=
method.
Defined in:
assertions/not_equal_to.crConstructors
Instance Method Summary
-
#default_message_template : String
Returns the default
#message_template
to use if no message is provided. -
#message : String
The message to display if
self
is not valid. -
#valid? : Bool
Returns
true
if a property satisfiesself
, otherwisefalse
.
Instance methods inherited from class Assert::Assertions::Assertion
default_message_template : String
default_message_template,
groups : Array(String)
groups,
message : String
message,
message_template : String
message_template,
property_name : String
property_name,
valid? : Bool
valid?
Constructor methods inherited from class Assert::Assertions::Assertion
new(property_name : String, message : String | Nil = nil, groups : Array(String) | Nil = nil)
new
Constructor Detail
def self.new(property_name : String, actual : PropertyType, value : PropertyType, message : String | Nil = nil, groups : Array(String) | Nil = nil)
#
Instance Method Detail
def default_message_template : String
#
Returns the default #message_template
to use if no message is provided.
def message : String
#
The message to display if self
is not valid.
NOTE This method is defined automatically, and is just present for documentation purposes.