An attribute is allowed if it's white listed
 or it's a valid attribute and not black listed
 @param name [Symbol]
 @param user [User] who is performing request
555200
def setting_attribute_is_allowed?(name, user)
            return false unless user.can_write?(self, name)
            (self.whitelisted_attributes && self.whitelisted_attributes.has_key?( name.to_sym)) ||
            (
              self.attribute_names.include?( name.to_s ) &&
              ( self.blacklisted_attributes.nil? ||
                ! self.blacklisted_attributes.has_key?( name.to_sym )  )
            )
        end
463422
def flag_color=(flag_color)
      validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
      unless validator.valid?(flag_color)
        fail ArgumentError, 'invalid value for "flag_color", must be one of #{validator.allowable_values}.'
      end
      @flag_color = flag_color
    end
641507
function SetUserAttributedTokens(
      $first_param,
      $second_param = "*-*"
  ) {
      $result = "";
      if ($second_param == "*-*") {
          $result = $first_param;
      } else {
          $this->SetUser($first_param);
          $result = $second_param;
      }
      $this->_user_data['attributed_tokens'] = $result;

      return $result;
  }
541315
def user_is_blacklisted(self, user):
        '''
        
        '''
        return not salt.utils.stringutils.check_whitelist_blacklist(user, blacklist=self.blacklist.get('users', []))
1236368
private void renderAttribute(InternalStringBuilder buf, String name, String value)
    {
        assert (name != null);
        if (value == null)
            return;

        buf.append(" ");
        buf.append(name);
        buf.append("=\"");
        buf.append(value);
        buf.append("\"");
    }
1236018
def write_attribute(name, value)
      name = name.to_s
      modify(name, @attributes[name], value)
    end
294353
def attribute(name, options = {})
        return unless
          @_object &&
          attribute_present?(name) &&
          resolve_condition(options)

        attribute = data_object_attribute(name)
        name = create_key(options[:as] || name)
        @_result[name] = attribute
      end
94634
def is_valid(self, name, value):
        
        if name not in self.header_types:
            return False
        t = self.header_types[name]
        if t == ATTR_TYPE_DISCRETE:
            return isinstance(value, int)
        elif t == ATTR_TYPE_CONTINUOUS:
            return isinstance(value, (float, Decimal))
        return True
1337577
public boolean isValid() {
    boolean result = true;

    // The username attribute will always be required.
    result = (this.getUsername() != null);

    if (result == true && this.requiredTokenAttributes != null) {
      for (String attr : this.requiredTokenAttributes) {
        if (this.get(attr) == null) {
          result = false;
          break;
        }
      }
    }

    return result;
  }
676213
def user(val, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    if not isinstance(val, six.integer_types):
        # Try to convert to integer. This will fail if the value is a
        # username. This is OK, as we check below to make sure that the
        # value is either a string or integer. Trying to convert to an
        # integer first though will allow us to catch the edge case in
        # which a quoted uid is passed (e.g. '1000').
        try:
            val = int(val)
        except (TypeError, ValueError):
            pass
    if not isinstance(val, (six.integer_types, six.string_types)):
        raise SaltInvocationError('Value must be a username or uid')
    elif isinstance(val, six.integer_types) and val < 0:
        raise SaltInvocationError('\'{0}\' is an invalid uid'.format(val))
    return val
1346815
@SuppressWarnings("unchecked")
    private <A> A getRequestAttribute(String name) {

        Object attribute = m_request.getAttribute(name);

        return attribute != null ? (A)attribute : null;
    }
368733
def check_unique_attr(self, attrs, user=None, form=None, flash_msg=None):
        
        user = user or self.current
        ucol = self.options["username_column"]
        email = self.options["email_column"]
        if not isinstance(attrs, (list, tuple, dict)):
            attrs = [attrs]

        for name in attrs:
            if isinstance(attrs, dict):
                value = attrs[name]
            else:
                form = form or current_context.data.get("form")
                if not form:
                    raise OptionMissingError("Missing 'value' option or form in 'check_user_unique_attr' action")
                value = form[name].data

            if name == ucol and not self.options["username_case_sensitive"]:
                filters = (ucol + '_lcase', value.strip().lower())
            elif name == emailcol:
                filters = (emailcol, value.strip().lower())
            else:
                filters = (name, value.strip())

            if self.query.filter({"$and": [filters, ("id__ne", user.id)]}).count() > 0:
                if flash_msg is None:
                    flash_msg = "The %s is already in use" % name
                if flash_msg:
                    flash(flash_msg, "error")
                current_context.exit(trigger_action_group="user_attr_not_unique")
613290
protected void checkAttribute(String attribute) {
        if (!hasAttribute(attribute)) {
            String sb = "Attribute: '" + attribute + "' is not defined in model: '" + getModelClass() + ". "
                    + "Available attributes: " +getAttributeNames();
            throw new IllegalArgumentException(sb);
        }
    }
43020
def attribute_prefix=(attribute_prefix)
      if attribute_prefix.nil?
        fail ArgumentError, "attribute_prefix cannot be nil"
      end

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

      @attribute_prefix = attribute_prefix
    end
1312006
def _pv_name_attribute(opts, key, is_name_attribute=true)
        if is_name_attribute
          if opts[key] == nil
            opts[key] = self.instance_variable_get("@name")
          end
        end
      end
953246
function checkUserColors(colorUser){
  if(terminal.colors){
    for(var name in colorUser){
      colorUser[name]= setUserColor(colorUser[name]);
      }
  }
  else{
    throw new Error("There is no colors object defined");
  }
}
91588
def set_attribute_data(data, user)
            return {} unless self.can_write_attributes?(data, user)
            data.each_with_object(Hash.new) do | (key, value), result |
                # First we set all the attributes that are allowed

                if self.setting_attribute_is_allowed?(key.to_sym, user)
                    result[key] = value
                    public_send("#{key}=", value)
                elsif value.present?
                    # allow nested params to be specified using Rails _attributes
                    name = key.to_s.gsub(/_attributes$/,'').to_sym

                    next unless self.class.has_exported_nested_attribute?(name, user)

                    association = self.association(name)
                    if value.is_a?(Hash) && [:belongs_to,:has_one].include?(association.reflection.macro)
                        target = send(name) || association.build
                        result[name] = target.set_attribute_data(value, user)
                    elsif value.is_a?(Array) && :has_many == association.reflection.macro
                        result[name] = _set_attribute_data_from_collection(association, name, value, user)
                    end
                end
            end
        end