module ValidateMyRoutes::Validate::RulesCombinators

Helper functions to provide a DSL for creating validation rules

Public Instance Methods

and(other_rule) click to toggle source

Chain rule with another one to perform both validations Note that if first rule fails validation, second is ignored

required.and of_type(Integer)
# File lib/validate_my_routes/validate/mixins/rules_combinators.rb, line 17
def and(other_rule)
  ValidateMyRoutes::ValidationRules.and(self, other_rule)
end
negate() click to toggle source

Negate the rule to validate opposite expectation

is_an_integer = of_type(Integer)
is_not_an_integer = of_type(Integer).negate
# File lib/validate_my_routes/validate/mixins/rules_combinators.rb, line 9
def negate
  ValidateMyRoutes::ValidationRules.not self
end
or(other_rule) click to toggle source

Chain rule with another one to perform one or another validations Note that second validation will be performed only if first fails

eql('all').or of_type(Integer)
# File lib/validate_my_routes/validate/mixins/rules_combinators.rb, line 25
def or(other_rule)
  ValidateMyRoutes::ValidationRules.or(self, other_rule)
end