class CrSerializer::Assertions::GreaterThanAssertion(ActualValueType)

Overview

Validates a property is greater than a value

Usable on any type that includes Comparable

@[Assert::GreaterThan(value: 100)]
property age : Int64

NOTE value can be: a hardcoded value like 10, the name of another property, or the name of a method

NOTE Nil values are considered valid

Defined in:

CrSerializer/assertions/greater_than.cr

Constructors

Instance Method Summary

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, 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, value : ActualValueType) #

[View source]

Instance Method Detail

def actual #

The current value of the property


def error_message : String #

The message that will be shown if the assertion is not valid


[View source]
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.


[View source]