Will loop on each field of the given form, and get every translations for
the validation rules messages.

@return $this
18853
public function injectTranslationsForFormFieldsValidation()
    {
        $formConfiguration = $this->getFormObject()->getConfiguration();

        foreach ($formConfiguration->getFields() as $field) {
            $this->storeTranslationsForFieldValidation($field);
        }

        return $this;
    }
102452
final public function init()
    {
        $sm = $this->getServiceLocator();
        $config = $sm->get($this->moduleService)->config();
        if (array_key_exists('*', $config)) {
            // Inject form instance if * is closure
            if (is_object($config['*']) && $config['*'] instanceof \Closure) {
                $form = $config['*']($this);
            }
        }
        $this->initialize();
        // Initialize form elements
        foreach ($this->getFormElements() as $element) {
            $elementOptions = array();
            if (array_key_exists($element['name'], $this->formElementOptions)) {
                $elementOptions = $this->formElementOptions[$element['name']];
            }
            // Add id attribute for each element
            if (!array_key_exists('attributes', $element)) {
                $element['attributes'] = array();
                $element['attributes'] ['id'] = $element['name'];
            } else {
                $element['attributes'] ['id'] = $element['name'];
            }
            $this->add($element, $elementOptions);
        }
        return $this;
    }
561705
public function translations()
    {
        if (is_null($this->translationsClass))
            $this->translationsClass = get_class($this) . 'Translations';

        return $this->hasMany($this->translationsClass, 'record_id', 'id');
    }
981300
private function transpileFields()
    {
        $formElements = 'input, select, textarea, button';

        $this->findFormTag()->filter($formElements)->each(
            function (Crawler $node, $i) {

                // If it has a type attr, use as type
                if (null !== $node->attr('type')) {
                    $type = $node->attr('type');
                } else {
                    $type = $node->nodeName();
                }

                // Node name cames back with apostrophs on some servers
                $type = str_replace('\"', '', $type);
                // Create a FormField and get default attributes (name, value, validation, required)
                $field = $this->fieldFactory($type, $node);


                // complex form elements 1: select -> options
                if ($type === 'select') {
                    $options = $node->filter('option');

                    // FormField
                    $options->each(
                        function ($option) use ($field) {
                            $optionField = $this->fieldFactory('option', $option);
                            $field->addOption($optionField);
                        }
                    );
                }

                // complex form elements: handle file uploads
                if ($type === 'file') {
                    try {
                        $field->compactFiles($_FILES, $this->uploadDir);
                    } catch (NoFileUploadedException $noFileEx) {
                        // throw validation error?
                    }
                }

                // Add to all fields
                $this->fields[$field->getName()] = $field;

            }
        );

        return $this->fields;
    }
712777
public function validateRequired()
    {
        $this->validator_attributes[] = 'data-parsley-required';

        $this->field_required = true;

        $this->validator_checks['required'] = true;

        return $this;
    }
566320
public function getValidationMessage(): array{
        $fields = [];
        foreach ($this->validations as $validation) {
            /* @var Validation $validation */
            if ($validation->getStatus() == Validation::ERROR) {
                if (!isset($fields[$validation->getField()])) {
                    $fields[$validation->getField()] = [];
                }
                var_dump($validation->getMessage());
                array_push($fields[$validation->getField()], $validation->getMessage());
            }
        }
        return $fields;
    }
1211072
public function filterFields()
    {
        // If filtering is unlocked/allowed we can start with filtering process.
        if (!$this->isFilteringLocked()) {
            $filters = array_filter($this->getFilters());

            if (count($filters)) {
                $dotForm = $this->formHelper->transformToDotSyntax($this->getName());

                $request = $this->getRequest();
                $requestData = $request->all();

                foreach ($filters as $field => $fieldFilters) {
                    $dotField = $this->formHelper->transformToDotSyntax($field);
                    $fieldData = Arr::get($requestData, $dotField);
                    if ($fieldData !== null) {
                        // Assign current Raw/Unmutated value from request.
                        $localDotField = preg_replace('#^' . preg_quote("$dotForm.", '#') . '#', '', $dotField);
                        $localBracketField = $this->formHelper->transformToBracketSyntax($localDotField);
                        $this->getField($localBracketField)->setRawValue($fieldData);
                        foreach ($fieldFilters as $filter) {
                            $filterObj = FilterResolver::instance($filter);
                            $fieldData = $filterObj->filter($fieldData);
                        }
                        Arr::set($requestData, $dotField, $fieldData);
                    }
                }

                foreach ($requestData as $name => $value) {
                    $request[$name] = $value;
                }
            }
        }

        return $this;
    }
378756
public function setForm($form)
    {
        // Associate Form Instance (via parent):
        
        parent::setForm($form);
        
        // Associate Rules with Fields:
        
        foreach ($this->rules as $fieldName => $rules) {
            
            if ($field = $this->getDataField($fieldName)) {
                
                foreach ($rules as $rule) {
                    $rule->setField($field);
                }
                
            }
            
        }
        
        // Associate Backend with Self:
        
        $this->backend->setFrontend($this);
        
        // Initialise Backend:
        
        $this->backend->doInit();
        
        // Define Form Classes:
        
        if ($classes = $this->getClassesForForm($form)) {
            
            foreach ($classes as $class) {
                $form->addExtraClass($class);
            }
            
        }
        
        // Define Form Attributes:
        
        if ($attributes = $this->getAttributesForForm($form)) {
            
            foreach ($attributes as $key => $value) {
                $form->setAttribute($key, $value);
            }
            
        }
        
        // Answer Self:
        
        return $this;
    }
1205089
public function rules($field, array $rules)
    {
        foreach ($rules as $rule)
        {
            $this->rule($field, $rule[0], Arr::get($rule, 1));
        }

        return $this;
    }
859133
private function translate(): self
    {
        if (empty($this->translations)) {
            return $this;
        }

        $lang = $this->get('lang');

        foreach ($this->attributes as $key => $attribute) {
            if (in_array($key, $this->translations, true)) {
                $this->set($key, __($attribute, [], $lang));
            }
        }

        return $this;
    }
890492
public function validateRules()
    {
        $input = request()->all();
        $rules = [];
        $messages = [];

        if ($this->formRequest) {
            $this->formRequest = new $this->formRequest;
            $rules = $this->formRequest->rules();
            $messages = $this->formRequest->messages();
        }

        return Validator::make($input, $rules, $messages);
    }
709575
function() {
		var input, inputName, state, message,
		returnedObj = { fields:{}, validate:true };
      
      // Loop on all the sub fields
      for (var i = 0 ; i < this.inputs.length ; i++) {
	
   	   input = this.inputs[i];
			inputName = input.options.name;
   	   state = input.getState();
			message = input.getStateString(state);
						
			returnedObj.fields[inputName] = {};
			returnedObj.fields[inputName].valid = true;
			returnedObj.fields[inputName].message = message;
			
			// check if subfield validates
   	   if( state == inputEx.stateRequired || state == inputEx.stateInvalid ) {
				returnedObj.fields[inputName].valid = false;
				returnedObj.validate = false;
   	   }

      }

      return returnedObj;
	}
544518
public function errorMessages()
    {
        $messages = array();

        // Loop over each field
        foreach ($this->errors as $field => $errors) {
            $messages[$field] = array();

            // Loop over the fields errors
            foreach ($errors as $validation => $error) {
                $vars = array_merge(
                    array('field' => Language::translate($field)),
                    $error
                );
                unset($vars['message']);
                $messages[$field][] = Language::translate($error['message'], $vars);
            }
        }

        return $messages;
    }
110761
public function generate() {

		$methods   = array(); // Actual validation methods
		$rules     = array(); // Individual field rules
		$messages  = array(); // Field error messages
		$php_rules = $this->validator->get_rules();


		foreach($php_rules as $field_name => $field_rules) {

			$rules[$field_name] = array();

			foreach($field_rules as $rule) {

				if( ! ($rule instanceof jQueryValidationRule) ) continue;
				$rule_name = $rule->jquery__get_rule_name();


				if(!isset($methods[$rule_name])) {
					$method = method_exists($rule, 'jquery__get_method_definition') ? $rule->jquery__get_method_definition() : null;
					if($method) $methods[$rule_name] = $method;
				}


				$js_rule = $rule->jquery__get_rule_definition();

				if(is_array($js_rule)) {
					$rules[$field_name] = array_merge($rules[$field_name], $js_rule);
				} else {
					$rules[$field_name][$js_rule] = true;
				}


				$messages[$field_name][$rule_name] = $rule->get_error_message($field_name, null, $this->validator);

			}

			if(empty($rules[$field_name])) unset($rules[$field_name]);
			if(empty($messages[$field_name])) unset($messages[$field_name]);

		}


		return array(
			'rules'    => $rules,
			'messages' => $messages,
			'methods'  => $methods,
		);

	}
158401
final public function validate($form)
    {
        $this->initializeValidator($form);

        $formObject = $this->formValidatorExecutor->getFormObject();
        $formObject->markFormAsSubmitted();
        $formObject->setForm($form);

        $this->validateGhost($form, false);

        $formObject->setFormResult($this->result);

        return $this->result;
    }
202238
public function getMessageBag()
    {
        if (Application::getInstance()->runningInConsole()) {
            return $this->validator->with($this->inputs)->getMessageBag();
        }

        return $this->formBuilder->getMessageBag();
    }
125690
protected function buildFields()
    {
        $messages = (isset($this->validator)) ? $this->validator->messages() : false;

        foreach ($this->fields as $field) {
            $field->status = $this->status;
            $field->orientation = $this->orientation;
            $field->has_label = $this->has_labels;
            $field->has_placeholder = $this->has_placeholders;
            if ($messages and $messages->has($field->name)) {
                $field->messages = $messages->get($field->name);
                $field->has_error = " has-error";
            }
            $field->build();
        }
    }