Module: Mixture::Extensions::Validatable::ClassMethods

Defined in:
lib/mixture/extensions/validatable.rb

Overview

The class methods.

Instance Method Summary collapse

Instance Method Details

#validate(name, options = {}) ⇒ void

This method returns an undefined value.

Creates a new validation for the given attribute. The attribute must be defined before this call, otherwise it will error.

Parameters:

  • name (Symbol)

    The name of the attribute to validate.

  • options (Hash) (defaults to: {})

    The options for validation. This is normally a key-value pair, where the key is the name of the validator, and the value is the options to pass to the validator.



21
22
23
# File 'lib/mixture/extensions/validatable.rb', line 21

def validate(name, options = {})
  attributes.fetch(name).options[:validate] = options
end