/** * Validation data * * @param array $data * @return mixed * @throws FormValidationException */ public function validate(array $data) { $this->validation = $this->validator->make($data, $this->rules(), $this->messages()); if ($this->validation->fails()) { throw new FormValidationException("Validation Failed", $this->errors()); } return true; }
/** * Validate the form data * * @throws FormValidationException * whenever the validation fails * * @param mixed $formData * * @return bool */ public function validate($formData) { $formData = $this->normalizeFormData($formData); $this->validation = $this->factory->make($formData, $this->getValidationRules(), $this->getValidationMessages()); if ($this->validation->fails()) { throw new FormValidationException('Validation failed', $this->getValidationErrors()); } return true; }
public function addChild($child, array $options = array()) { if (!$child instanceof ItemInterface) { $child = $this->factory->createItem($child, $options); } elseif (null !== $child->getParent()) { throw new \InvalidArgumentException('Cannot add menu item as child, it already belongs to another menu (e.g. has a parent).'); } $child->setParent($this); $this->children[$child->getName()] = $child; return $child; }
/** * Builds validator using validation factory. * * @param array $data * @param array $rules * @param array $messages * * @return ValidatorInterface */ public function makeValidator(array $data, array $rules, array $messages = []) { return $this->validationFactory->make($data, $rules, $messages); }
/** * Get template * * @return \Magento\Framework\Mail\TemplateInterface */ protected function getTemplate() { return $this->templateFactory->get($this->templateIdentifier)->setVars($this->templateVars)->setOptions($this->templateOptions); }