/** * Adds a single attribute to this validator. * @param string $field The attribute these rules apply to. Optionally specify a name for the rules by adding a * colon(":") followed by the name. E.g. "question:Security Question" * @param string $rule List of validators from the Respect\Validation package separated by the pipe ("|") character. */ public function addAttribute($field, $rule) { $attributeRule = new AllOf(); $attributeRule->addRules($this->createRulesArray($rule)); $name = $field; // Get name if one was provided if (($colon = strpos($field, ':')) !== false) { $name = substr($field, $colon + 1); $field = substr($field, 0, $colon); } $attribute = new Key($field, $attributeRule); $attribute->setName($name); $this->addRule($attribute); }