module ErrorProne::Validator::ClassMethods

Public Instance Methods

rules() click to toggle source

Contains rules the validator will run when .validate! is called

@return (ErrorProne::RuleSet)

# File lib/error_prone.rb, line 133
def rules
  @rules ||= RuleSet.new
end
validate!(object) click to toggle source

Validates all rules against the given object

@param (Object) object Object to validate each rule against @return (Boolean) True if all rules are valid, false otherwise.

# File lib/error_prone.rb, line 151
def validate!(object)
  rules.all_valid_for? object
end
validates(field, rule, options={}) click to toggle source

Adds a rule the validator runs when .validate! is called.

@param (Symbol) field Method to call on the object to validate @param (Symbol) rule Name of rule to apply, defined by {ErrorProne::Rule}.validates_as @param (Hash) options to pass to the {ErrorProne::Rule} when instantiating

# File lib/error_prone.rb, line 143
def validates(field, rule, options={})
  rules.add(field, rule, options)
end