Custom attribute writer method with validation
 @param [Object] merchant_support_email Value to be assigned
490385
def merchant_support_email=(merchant_support_email)

      if !merchant_support_email.nil? && merchant_support_email.to_s.length > 254
        fail ArgumentError, "invalid value for 'merchant_support_email', the character length must be smaller than or equal to 254."
      end

      @merchant_support_email = merchant_support_email
    end
1105712
def extract_inclusion_values(klass, attribute)
      values = nil

      klass.validators_on(attribute).each do |validator|
        case validator
        when ActiveModel::Validations::InclusionValidator
          values = validator.options[:in]
        end
      end

      values
    end
1114094
def refund_id=(refund_id)
      if refund_id.nil?
        fail ArgumentError, "refund_id cannot be nil"
      end

      if refund_id.to_s.length < 1
        fail ArgumentError, "invalid value for 'refund_id', the character length must be great than or equal to 1."
      end

      @refund_id = refund_id
    end
437083
def validate_email(self, email_address):

        '''
            
        '''

        title = '%s.validate_email' % __class__.__name__

    # validate inputs
        object_title = '%s(email_address="")' % title
        email_address = self.fields.validate(email_address, '.email_address', object_title)

    # construct request_kwargs
        request_kwargs = {
            'url': '%s/address/validate' % self.api_endpoint,
            'params': { 'address': email_address }
        }

    # send request
        response_details = self._get_request(**request_kwargs)

        return response_details
61654
def validate_attributes
      unless address.present? || (lat.present? && lng.present?)
        raise ArgumentError, 'Must provide an address, or lat and lng.'
      end

      if address.present? && lat.present? && lng.present?
        raise ArgumentError, 'Cannot provide address, lat and lng.'
      end
    end
986056
def attributes=(attributes)
      model = self.model
      attributes.each do |name, value|
        case name
          when String, Symbol
            if model.allowed_writer_methods.include?(setter = "#{name}=")
              __send__(setter, value)
            else
              raise ArgumentError, "The attribute '#{name}' is not accessible in #{model}"
            end
          when Associations::Relationship, Property
            # only call a public #typecast (e.g. on Property instances)
            if name.respond_to?(:typecast)
              value = name.typecast(value)
            end
            self.persistence_state = persistence_state.set(name, value)
        end
      end
    end
86330
def order=(order)
      validator = EnumAttributeValidator.new('String', ["DESC", "ASC"])
      unless validator.valid?(order)
        fail ArgumentError, "invalid value for 'order', must be one of #{validator.allowable_values}."
      end
      @order = order
    end
5427
def valid?
      return false if @id.nil?
      return false if @created_at.nil?
      return false if @updated_at.nil?
      creation_source_validator = EnumAttributeValidator.new('String', ["OTHER", "APPOINTMENTS", "COUPON", "DELETION_RECOVERY", "DIRECTORY", "EGIFTING", "EMAIL_COLLECTION", "FEEDBACK", "IMPORT", "INVOICES", "LOYALTY", "MARKETING", "MERGE", "ONLINE_STORE", "INSTANT_PROFILE", "TERMINAL", "THIRD_PARTY", "THIRD_PARTY_IMPORT", "UNMERGE_RECOVERY"])
      return false unless creation_source_validator.valid?(@creation_source)
      return true
    end
906440
def action=(action)
      validator = EnumAttributeValidator.new('String', ["COMPLETE", "CANCEL", "REFUND"])
      unless validator.valid?(action)
        fail ArgumentError, "invalid value for 'action', must be one of #{validator.allowable_values}."
      end
      @action = action
    end
1370657
def valid_email?(email)
      mail = Mail::Address.new(email)

      # We must check that value contains a domain and that value is 
      # an email address
      result = mail.domain && mail.address == email
      tree = mail.__send__(:tree)

      # We need to dig into treetop. A valid domain must have 
      # dot_atom_text elements size > 1. Addresses like user@localhost 
      # are excluded. Treetop must respond to domain.
      result && (tree.domain.dot_atom_text.elements.size > 1)
    rescue => e
      false
    end
902655
def itemization_type=(itemization_type)
      validator = EnumAttributeValidator.new('String', ["ITEM", "CUSTOM_AMOUNT", "GIFT_CARD_ACTIVATION", "GIFT_CARD_RELOAD", "GIFT_CARD_UNKNOWN", "OTHER"])
      unless validator.valid?(itemization_type)
        fail ArgumentError, "invalid value for 'itemization_type', must be one of #{validator.allowable_values}."
      end
      @itemization_type = itemization_type
    end
816248
def validate(context = Attributor::DEFAULT_ROOT_CONTEXT)
      raise AttributorException, 'validation conflict' if @validating
      @validating = true

      context = [context] if context.is_a? ::String
      keys_with_values = []
      errors = []

      self.class.attributes.each do |sub_attribute_name, sub_attribute|
        sub_context = self.class.generate_subcontext(context, sub_attribute_name)

        value = __send__(sub_attribute_name)
        keys_with_values << sub_attribute_name unless value.nil?

        if value.respond_to?(:validating) # really, it's a thing with sub-attributes
          next if value.validating
        end

        errors.concat sub_attribute.validate(value, sub_context)
      end
      self.class.requirements.each do |req|
        validation_errors = req.validate(keys_with_values, context)
        errors.concat(validation_errors) unless validation_errors.empty?
      end

      errors
    ensure
      @validating = false
    end
679069
def sender_name=(v)
      @sender_name = nil
      if (v = sanitize(v)) && v.length > 0
        @sender_name = v
      else
        raise USPSValidationError, "'#{v}' is not a valid string in #{__method__}"
      end
    end
733196
def validate(self, value):
        ""

        # Use the parent's handling of required fields, etc.
        super(MultiEmailField, self).validate(value)

        for email in value:
            validate_email(email)
333174
def validator_params
      wildcard = params.try(:[], :validator).try(:[], :resource_instance_additional_params).try(:keys)
      params.require(:validator).
      permit(:form_object,
             :resource_model,
             :resource_attr_name,
             :resource_attr_value,
             :ignore_resource_attr_value,
             :resource_instance_additional_params => wildcard)
    end
934434
def valid_input?(input)
      case @attributes[:type]
      when :boolean
        [true,false].include?(input)
      when :enum
        raise MissingValuesError unless @attributes[:values]
        raise InvalidValuesError unless @attributes[:values].class == Array
        @attributes[:values].include?(input)
      when :string
        format = @attributes[:format] || :anything
        Validator.valid_input?(format, input)
      when :number
        [Integer, Fixnum].include?(input.class)
      when :timestamp
        # TODO timestamp pending
        # raise PendingBranchError
        true
      else
        false
      end
    end
826716
def method=(method)
      validator = EnumAttributeValidator.new('String', ["ENUM", "FC"])
      unless validator.valid?(method)
        fail ArgumentError, "invalid value for 'method', must be one of #{validator.allowable_values}."
      end
      @method = method
    end