lib/key_vortex/constraint/length.rb in key-vortex-0.1.4 vs lib/key_vortex/constraint/length.rb in key-vortex-0.2.0
- old
+ new
@@ -3,22 +3,26 @@
require "key_vortex/constraint/base"
class KeyVortex
class Constraint
class Length < KeyVortex::Constraint::Base
- attr_reader :value
+ attr_reader :limit
- def initialize(value)
+ def initialize(limit)
super()
- @value = value
+ @limit = limit
end
def attribute
:length
end
def within?(constraint)
- super && value <= constraint.value
+ super && limit <= constraint.limit
+ end
+
+ def accepts?(value)
+ value.length <= limit
end
end
end
end