Class: ZohoHub::Validations::ValidateLength

Inherits:
BaseValidation show all
Defined in:
lib/zoho_hub/validations/validate_length.rb

Instance Attribute Summary

Attributes inherited from BaseValidation

#field, #record

Instance Method Summary collapse

Methods inherited from BaseValidation

#initialize

Constructor Details

This class inherits a constructor from ZohoHub::Validations::BaseValidation

Instance Method Details

#validate(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/zoho_hub/validations/validate_length.rb', line 8

def validate(options = {})
  value = record.send(field)

  return unless value

  return if value.size <= options[:length]

  record.add_error(field, 'is too long')
end