Module: ZohoHub::WithValidations::ClassMethods

Defined in:
lib/zoho_hub/with_validations.rb

Instance Method Summary collapse

Instance Method Details

#add_validation(field, params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/zoho_hub/with_validations.rb', line 13

def add_validation(field, params = {})
  @validations ||= []

  options = params.dup
  validate = options.delete(:validate)

  unless validate
    raise ArgumentError, 'You must provide the validation with the `validate` key!'
  end

  @validations << { field: field, validate: validate }.merge(options)
end

#validationsObject



26
27
28
# File 'lib/zoho_hub/with_validations.rb', line 26

def validations
  @validations || []
end