lib/key_vortex/constraint.rb in key-vortex-1.1.0 vs lib/key_vortex/constraint.rb in key-vortex-1.1.1

- old
+ new

@@ -2,10 +2,11 @@ require "key_vortex/constraint/base" require "key_vortex/constraint/length" require "key_vortex/constraint/maximum" require "key_vortex/constraint/minimum" +require "key_vortex/constraint/regexp" class KeyVortex # Constraints define a restriction on the values which can be used # for {KeyVortex::Record} and {KeyVortex::Adapter}. Although they # are somewhat varied, they do have some common properties. @@ -23,12 +24,12 @@ # {KeyVortex::Constraint} is a module instead of the base class to # avoid a circular dependency. # # All constraints can determine if a value is valid for them. # - # All constraints, when compared with other instances of themselves, - # it can always be determined if ones limitations fit within the + # Most constraints, when compared with other instances of + # themselves, can be determined if ones limitations fit within the # others. More formally, given an instance x of a constraint, an # instance y of the same constraint fits within x if and only if for # all values v that are valid for y, v is also valid for x. module Constraint # Factory enabling the specification of constraints by attribute @@ -43,9 +44,11 @@ KeyVortex::Constraint::Length.new(limit) when :maximum KeyVortex::Constraint::Maximum.new(limit) when :minimum KeyVortex::Constraint::Minimum.new(limit) + when :regexp + KeyVortex::Constraint::Regexp.new(limit) else raise KeyVortex::Error, "Unexpected attribute: #{attribute}" end end end