app/models/fields/custom_field.rb
# Extra validation that is called on this field when validation happens
# obj is reference to parent object
#------------------------------------------------------------------------------
Extra validation that is called on this field when validation happens
obj is reference to parent object
Extra validation that is called on this field when validation happens obj is reference to parent object
def custom_validator(obj)
    attr = name.to_sym
    obj.errors.add(attr, ::I18n.t('activerecord.errors.models.custom_field.required', field: label)) if required? && obj.send(attr).blank?
    obj.errors.add(attr, ::I18n.t('activerecord.errors.models.custom_field.minlength', field: label)) if (minlength.to_i > 0) && (obj.send(attr).to_s.length < minlength.to_i)
    obj.errors.add(attr, ::I18n.t('activerecord.errors.models.custom_field.maxlength', field: label)) if (maxlength.to_i > 0) && (obj.send(attr).to_s.length > maxlength.to_i)
  end
def custom_validator ( obj ) attr = name . to_sym obj . errors . add ( attr , :: I18n . t ( 'activerecord.errors.models.custom_field.required' , field : label ) ) if required? && obj . send ( attr ) . blank? obj . errors . add ( attr , :: I18n . t ( 'activerecord.errors.models.custom_field.minlength' , field : label ) ) if ( minlength . to_i > 0 ) && ( obj . send ( attr ) . to_s . length < minlength . to_i ) obj . errors . add ( attr , :: I18n . t ( 'activerecord.errors.models.custom_field.maxlength' , field : label ) ) if ( maxlength . to_i > 0 ) && ( obj . send ( attr ) . to_s . length > maxlength . to_i ) end
Extra validation that is called on this field when validation happens
obj is reference to parent object
Extra validation that is called on this field when validation happens obj is reference to parent object
obj