Custom attribute writer method with validation
 @param [Object] break_type_id Value to be assigned
777288
def break_type_id=(break_type_id)
      if break_type_id.nil?
        fail ArgumentError, "break_type_id cannot be nil"
      end

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

      @break_type_id = break_type_id
    end
1225450
def attr_type_for(attribute)
    fields = self.class._module.fields
    field  = fields[attribute]
    raise UninitializedModule, "#{self.class.session.namespace_const}Module #{self.class._module.name} was not initialized properly (fields.length == 0)" if fields.length == 0
    raise InvalidAttribute, "#{self.class}._module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\nValid fields: #{self.class._module.fields.keys.sort.join(", ")}" if field.nil?
    raise InvalidAttributeType, "#{self.class}._module.fields[#{attribute}] does not have a key for \'type\'" if field["type"].nil?
    field["type"].to_sym
  end
601775
def _build_type_validator(value_type):
    """"""

    def type_validator(data):
        """Validate instances of a particular type."""
        if isinstance(data, value_type):
            return data

        raise NotValid('%r is not of type %r' % (data, value_type))

    return type_validator
1141496
def format_property_value(attr, type)
      return unless send(attr.to_sym).present?

      case type.to_sym
      when :integer
        send("#{attr.to_sym}=", send(attr.to_sym).to_i)
      when :float
        send("#{attr.to_sym}=", send(attr.to_sym).to_f)
      when :boolean
        send("#{attr.to_sym}=", ActiveModel::Type::Boolean.new.cast(send(attr.to_sym)))
      else
        raise ArgumentError, 'Supported types are :boolean, :integer, :float'
      end
    end
877296
def object_type=(object_type)
      validator = EnumAttributeValidator.new('String', ["ITEM", "DISCOUNT", "CATEGORY", "PLACEHOLDER"])
      unless validator.valid?(object_type)
        fail ArgumentError, "invalid value for 'object_type', must be one of #{validator.allowable_values}."
      end
      @object_type = object_type
    end
896829
def dnxhd_type=(dnxhd_type)
      validator = EnumAttributeValidator.new('String', ["36", "45", "60", "75", "90", "90x", "110", "115", "120", "145", "175x", "175", "185x", "185", "220x", "220"])
      unless validator.valid?(dnxhd_type)
        fail ArgumentError, "invalid value for 'dnxhd_type', must be one of #{validator.allowable_values}."
      end
      @dnxhd_type = dnxhd_type
    end
243666
def type=(type)
      validator = EnumAttributeValidator.new('String', ["PHYSICAL", "MOBILE"])
      unless validator.valid?(type)
        fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
      end
      @type = type
    end
243927
function(options) {
      return {

        /**
         * Check whether an attribute or a set of attributes are valid. It will default to use the model's current values but
         * you can pass in different values to use in the validation process instead.
         * @param attr {String or Object or Array} Either the name of the attribute, an array containing many attribute names, or
         * on object with attribute name to values
         * @param [value] {Any} a value to use for the attribute value instead of using the model's value.
         * @return undefined if no errors, a validation exception if a single attribute, or an object with attribute name as key
         * and the error as the value
         * @method preValidate
         */
        preValidate: function(attr, value) {
          var self = this,
              result = {},
              error;
          if (_.isArray(attr)) {
            _.each(attr, function(attr) {
              error = self.preValidate(attr);
              if (error) {
                result[attr] = error;
              }
            });
            return _.isEmpty(result) ? undefined : result;
          } else if (_.isObject(attr)) {
            _.each(attr, function(value, key) {
              error = self.preValidate(key, value);
              if (error) {
                result[key] = error;
              }
            });
            return _.isEmpty(result) ? undefined : result;
          } else {
            if (_.isUndefined(value) && isNestedModel(this)) {
              value = this.get(attr);
            }
            return validateAttr(this, value, attr);
          }
        },

        // Check to see if an attribute, an array of attributes or the
        // entire model is valid. Passing true will force a validation
        // of the model.
        isValid: function(option) {
          var flattened, attrs, error, invalidAttrs;

          option = option || getOptionsAttrs(options);

          if(_.isString(option)){
            attrs = [option];
          } else if(_.isArray(option)) {
            attrs = option;
          }
          if (attrs) {
            // Loop through all attributes
            _.each(attrs, function (attr) {
              var value;
              if (isNestedModel(this)) {
                value = this.get(attr);
              } else {
                value = flatten(this.attributes)[attr];
              }
              error = validateAttr(this, value, attr);
              if (error) {
                invalidAttrs = invalidAttrs || {};
                invalidAttrs[attr] = error;
              }
            }, this);
          }

          if (option === true) {
            invalidAttrs = this.validate();
          }
          if (invalidAttrs) {
            this.trigger('invalid', this, invalidAttrs, {validationError: invalidAttrs});
          }
          return attrs ? !invalidAttrs : this.validation ? this._isValid : true;
        },

        // This is called by Backbone when it needs to perform validation.
        // You can call it manually without any parameters to validate the
        // entire model.
        validate: function(attrs, setOptions){
          var model = this;
          var opt = _.extend({}, options, setOptions);
          var validatedAttrs = getValidatedAttrs(model, getOptionsAttrs(options));
          var allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs);
          var flattened = _.extend(flatten(allAttrs), attrs); // allow people to pass in nested attributes
          var changedAttrs = attrs ? flatten(attrs) : flattened;
          var result = validateModel(model, allAttrs, _.pick(flattened, _.keys(validatedAttrs)));
          model._isValid = result.isValid;

          // Trigger validated events.
          // Need to defer this so the model is actually updated before
          // the event is triggered.
          _.defer(function() {
            model.trigger('validated', model._isValid, model, result.invalidAttrs);
            model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
          });

          // Return any error messages to Backbone, unless the forceUpdate flag is set.
          // Then we do not return anything and fools Backbone to believe the validation was
          // a success. That way Backbone will update the model regardless.
          if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
            return result.invalidAttrs;
          }
        }
      };
    }
752246
def validate(resource)
      value = resource._attributes[attribute]

      if value && !types.any? { |type| value.is_a?(type) }
        short_name = type.to_s.split('::').last
        resource.errors.add(attribute, "must be a kind of #{short_name}")
      end
    end
65644
@JRubyMethod(name = "type_id=")
    public static IRubyObject set_type_id(IRubyObject self, IRubyObject type_id) {
        org.yecht.Node node = (org.yecht.Node)self.dataGetStructChecked();
        if(!type_id.isNil()) {
            node.type_id = type_id.convertToString().toString();
        }
        ((RubyObject)self).fastSetInstanceVariable("@type_id", type_id);
        return type_id;
    }
134297
def product_type=(product_type)
      validator = EnumAttributeValidator.new('String', ["REGULAR", "GIFT_CARD", "APPOINTMENTS_SERVICE", "RETAIL_ITEM", "RESTAURANT_ITEM"])
      unless validator.valid?(product_type)
        fail ArgumentError, "invalid value for 'product_type', must be one of #{validator.allowable_values}."
      end
      @product_type = product_type
    end
76048
def schedule_type=(schedule_type)
      validator = EnumAttributeValidator.new('String', ["SCHEDULED", "ASAP"])
      unless validator.valid?(schedule_type)
        fail ArgumentError, "invalid value for 'schedule_type', must be one of #{validator.allowable_values}."
      end
      @schedule_type = schedule_type
    end
31612
def type=(type)
      allowed_values = ["lti1"]
      if type && !allowed_values.include?(type)
        fail ArgumentError, "invalid value for 'type', must be one of #{allowed_values}."
      end
      @type = type
    end
952086
def action_type=(action_type)
      validator = EnumAttributeValidator.new('String', ['webhook', 'slack_webhook', 'email', 'aws_s3_upload'])
      unless validator.valid?(action_type)
        fail ArgumentError, 'invalid value for "action_type", must be one of #{validator.allowable_values}.'
      end
      @action_type = action_type
    end
631190
def validate_required_attributes!
      unless required_attributes?
        blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? }

        raise ValidationError, "#{blank_attribute} can't be blank"
      end
    end
1193331
def id=(id)

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

      @id = id
    end
823588
def sanitize_attributes(*args, &block)
      if (args.last && args.last.is_a?(Hash))
        options = args.pop
      end
      options ||= {}
      unless @sanitize_hook_already_defined
        include InstanceMethods
        extend ClassMethods

        if options[:before_validation]
          before_validation :sanitize!
        else
          before_save :sanitize!
        end

        cattr_accessor :sanitizable_attribute_hash
        cattr_accessor :sanitization_block_array
        self.sanitizable_attribute_hash ||= {}
        self.sanitization_block_array ||= []

        @sanitize_hook_already_defined = true
      end

      if block
        self.sanitization_block_array << block
        block = self.sanitization_block_array.index(block)
      else
        block = nil
      end

      args.each do |attr|
        self.sanitizable_attribute_hash[attr] = block
      end

      true
    end