get rule and parameters of a rules

@param {String}       attribute
@param {String|array} rules

@return {Array|null}
337107
function _getRule(attribute, rules) {
    rules = rules || [];

    if ( ! rules[attribute]) {
      return;
    }

    for(var i in rules[attribute]) {
      var value = rules[attribute][i];
      parsedRule = _parseRule(rule);

      if (in_array(parsedRule.rule, rules))
        return [parsedRule.rule, parsedRule.parameters];
    }
  }
1014198
function findAttribute(attrs, propName) {
    var index = Object.keys(attrs).filter(function (attr) {
      return attr.toLowerCase() === propName.toLowerCase();
    })[0];
    return attrs[index];
  }
520048
function filterAttributes(object, permissions) {
		if (object) {
			var userType = req.activeUser && req.activeUser.type || 'null';
			for (var attribute in object._doc) {
				if (object._doc.hasOwnProperty(attribute)) {
					// dont return this attribute when:
					if (!permissions[attribute] || // if this attribute is not defined in permissions
						permissions[attribute][0] !== 'null' && // this attribute is not set as public
						permissions[attribute].indexOf(userType) === -1 && // this attribute is not available to this userType
						userType !== 'admin' // the user is not admin
					) {
						delete object._doc[attribute];
					}
				}
			}
		}

		return object;
	}
996776
function _getAttribute(attribute) {
    if (is_string(_attributes[attribute])) {
      return _attributes[attribute];
    }

    if ((line = _translator.trans(attribute)) !== attribute) {
      return line;
    } else {
      return attribute.replace('_', ' ');
    }
  }
101017
function () {
    var self = this;

    for (var attribute in this.rules) {
      var attributeRules = this.rules[attribute];
      var inputValue = this._objectPath(this.input, attribute);

      if (this._hasRule(attribute, ['sometimes']) && !this._suppliedWithData(attribute)) {
        continue;
      }

      for (var i = 0, len = attributeRules.length, rule, ruleOptions, rulePassed; i < len; i++) {
        ruleOptions = attributeRules[i];
        rule = this.getRule(ruleOptions.name);

        if (!this._isValidatable(rule, inputValue)) {
          continue;
        }

        rulePassed = rule.validate(inputValue, ruleOptions.value, attribute);
        if (!rulePassed) {
          this._addFailure(rule);
        }

        if (this._shouldStopValidating(attribute, rulePassed)) {
          break;
        }
      }
    }

    return this.errorCount === 0;
  }
967121
function (rules) {
		if (!_.isArray(rules)) {
			rules = [ rules ];
		}

		var that = this;

		return _.map(rules, function (rule) {
			if (typeof rule === 'string') {
				return that._parseString(rule);
			}

			if (_.isPlainObject(rule)) {
				return that._parseObject(rule);
			}

			throw new Error('#V1: invalid rule type, must be string or plain object');
		});
	}
1087497
public function each( $attribute, $rules )
	{
		$data = Arr::dot( $this->initializeAttributeOnData( $attribute ) );

		$pattern = str_replace( '\*', '[^\.]+', preg_quote( $attribute ) );

		$data = array_merge( $data, $this->extractValuesForWildcards( $data, $attribute ) );

		foreach ( $data as $key => $value )
		{
			if ( Str::startsWith( $key, $attribute ) || (bool) preg_match( '/^' . $pattern . '\z/', $key ) )
			{
				foreach ( (array) $rules as $ruleKey => $ruleValue )
				{
					if ( !is_string( $ruleKey ) || Str::endsWith( $key, $ruleKey ) )
					{
						$this->implicitAttributes[$attribute][] = $key;

						$this->mergeRules( $key, $ruleValue );
					}
				}
			}
		}
	}
112893
function (ruleString) {
    var rule = {},
      ruleArray;

    rule.name = ruleString;

    if (ruleString.indexOf(':') >= 0) {
      ruleArray = ruleString.split(':');
      rule.name = ruleArray[0];
      rule.value = ruleArray.slice(1).join(":");
    }

    return rule;
  }
856341
function getScriptAttribute(source, attribute) {
        var matches;
        var regex = RegExp(attribute + "=(\"([^\"]*)\")|('([^']*)')", "gi");
        if (matches = regex.exec(source)) {
            return matches[2];
        }
        return null;
    }
532735
function getRule(recognizer, dfa) {
    const description = dfa.decision.toString();
    const ruleIndex = dfa.atnStartState.ruleIndex;

    const ruleNames = recognizer.ruleNames;
    if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
        return description;
    }
    const ruleName = ruleNames[ruleIndex] || '<unknown>';
    return description + " (" + ruleName + ")";
}
1057996
function getAttribute(babelTypes, attributes, name) { // {{{
  return (attributes || []).find(function (attr) {
    if (babelTypes.isJSXSpreadAttribute(attr)) {
      return false;
    }

    return attr.name.name === name;
  });
}
766265
function extractAttributeFields(attributeFields) {
  var attributes = {};
  if (attributeFields) {
    for (var field in attributeFields) {
      if (attributeFields[field].length > 0) {
        attributes[field] = attributeFields[field][0];
      }
    }
  }
  return attributes;
}
926260
function filterValidRule(rule) {
  return (rule.hasOwnProperty('match')&&typeof rule.match === "object")
  && (rule.hasOwnProperty('use') && (
    typeof rule.use === "object"
    || typeof rule.use === "function"
  ))
  && (
    (rule.match.hasOwnProperty('request'))
    || (rule.match.hasOwnProperty('base'))
  )
}
878283
function getAttributes(attributes) {
		var t = typeof attributes;
		if (t === 'string') {
			return attributes;
		}
		if (t === 'object') {
			return Object.keys(attributes).reduce(function (memo, key) {
				memo.push(key + '="' + attributes[key] + '"');
				return memo;
			}, []).join(' ');
		}
		return '';
	}
1196064
function(attributes, constraints, options) {
      var results = []
        , attr
        , validatorName
        , value
        , validators
        , validator
        , validatorOptions
        , error;

      if (v.isDomElement(attributes) || v.isJqueryElement(attributes)) {
        attributes = v.collectFormValues(attributes);
      }

      // Loops through each constraints, finds the correct validator and run it.
      for (attr in constraints) {
        value = v.getDeepObjectValue(attributes, attr);
        // This allows the constraints for an attribute to be a function.
        // The function will be called with the value, attribute name, the complete dict of
        // attributes as well as the options and constraints passed in.
        // This is useful when you want to have different
        // validations depending on the attribute value.
        validators = v.result(constraints[attr], value, attributes, attr, options, constraints);

        for (validatorName in validators) {
          validator = v.validators[validatorName];

          if (!validator) {
            error = v.format("Unknown validator %{name}", {name: validatorName});
            throw new Error(error);
          }

          validatorOptions = validators[validatorName];
          // This allows the options to be a function. The function will be
          // called with the value, attribute name, the complete dict of
          // attributes as well as the options and constraints passed in.
          // This is useful when you want to have different
          // validations depending on the attribute value.
          validatorOptions = v.result(validatorOptions, value, attributes, attr, options, constraints);
          if (!validatorOptions) {
            continue;
          }
          results.push({
            attribute: attr,
            value: value,
            validator: validatorName,
            globalOptions: options,
            attributes: attributes,
            options: validatorOptions,
            error: validator.call(validator,
                value,
                validatorOptions,
                attr,
                attributes,
                options)
          });
        }
      }

      return results;
    }
1283268
function extractAttributes(attrSet) {
		var reAttrName = /^[\w\-:\$@]+\.?$/;
		return splitAttributes(attrSet).map(function(attr) {
			// attribute name: [attr]
			if (reAttrName.test(attr)) {
				var value = '';
				if (attr.charAt(attr.length - 1) == '.') {
					// a boolean attribute
					attr = attr.substr(0, attr.length - 1);
					value = attr;
				}
				return {
					name: attr,
					value: value
				};
			}

			// attribute with value: [name=val], [name="val"]
			if (~attr.indexOf('=')) {
				var parts = attr.split('=');
				return {
					name: parts.shift(),
					value: unquote(parts.join('='))
				};
			}

			// looks like it’s implied attribute
			return {
				name: DEFAULT_ATTR_NAME,
				value: unquote(attr)
			};
		});
	}
1344617
function getAttribute(path, attrNode) {
    path.forEach(attrName => {
        if (!(attrNode.attributes && attrNode.attributes[attrName])) {
            throw new ImplementationError(`Result-Builder: Unknown attribute "${path.join('.')}"`);
        }
        attrNode = attrNode.attributes[attrName];
    });
    return attrNode;
}