Class: NxtSchema::Validators::GreaterThanOrEqual
- Defined in:
- lib/nxt_schema/validators/greater_than_or_equal.rb
Instance Attribute Summary collapse
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(threshold) ⇒ GreaterThanOrEqual
constructor
A new instance of GreaterThanOrEqual.
Methods inherited from Validator
Constructor Details
#initialize(threshold) ⇒ GreaterThanOrEqual
Returns a new instance of GreaterThanOrEqual.
4 5 6 |
# File 'lib/nxt_schema/validators/greater_than_or_equal.rb', line 4 def initialize(threshold) @threshold = threshold end |
Instance Attribute Details
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
9 10 11 |
# File 'lib/nxt_schema/validators/greater_than_or_equal.rb', line 9 def threshold @threshold end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nxt_schema/validators/greater_than_or_equal.rb', line 11 def build lambda do |node, value| if value >= threshold true else = translate_error(node.locale, value: value, threshold: threshold) node.add_error() end end end |