protected function optimizeValidations()
    {
        if (!$this->field->isNullable && !in_array('required', $this->field->validationRules)) {
            array_unshift($this->field->validationRules, 'required');
        }

        if (($rule = $this->field->getDateValidationRule()) != null && !in_array($rule, $this->field->validationRules)) {
            $this->field->validationRules[] = $rule;
        }

        if (!$this->field->isOnFormView) {
            // At this point we know the field is not going to be on any request form
            // remove all validation rules if any exists.
            $this->field->validationRules = [];
        }

        if ($this->field->isCheckBox() && $this->field->isBoolean()) {
            // At this point we know the field is a checkbox and is a boolean type
            // remove the required validation rule.
            $this->field->validationRules = array_filter($this->field->validationRules, function ($rule) {
                return $rule != 'required';
            });
        }

        return $this;
    }
protected function optimizeValidations()
    {
        if (!$this->field->isNullable && !in_array('required', $this->field->validationRules)) {
            array_unshift($this->field->validationRules, 'required');
        }

        if (($rule = $this->field->getDateValidationRule()) != null && !in_array($rule, $this->field->validationRules)) {
            $this->field->validationRules[] = $rule;
        }

        if (!$this->field->isOnFormView) {
            // At this point we know the field is not going to be on any request form
            // remove all validation rules if any exists.
            $this->field->validationRules = [];
        }

        if ($this->field->isCheckBox() && $this->field->isBoolean()) {
            // At this point we know the field is a checkbox and is a boolean type
            // remove the required validation rule.
            $this->field->validationRules = array_filter($this->field->validationRules, function ($rule) {
                return $rule != 'required';
            });
        }

        return $this;
    }
protected function optimizeValidations ( ) { if ( ! $ this -> field -> isNullable && ! in_array ( 'required' , $ this -> field -> validationRules ) ) { array_unshift ( $ this -> field -> validationRules , 'required' ) ; } if ( ( $ rule = $ this -> field -> getDateValidationRule ( ) ) != null && ! in_array ( $ rule , $ this -> field -> validationRules ) ) { $ this -> field -> validationRules [ ] = $ rule ; } if ( ! $ this -> field -> isOnFormView ) { // At this point we know the field is not going to be on any request form // remove all validation rules if any exists. $ this -> field -> validationRules = [ ] ; } if ( $ this -> field -> isCheckBox ( ) && $ this -> field -> isBoolean ( ) ) { // At this point we know the field is a checkbox and is a boolean type // remove the required validation rule. $ this -> field -> validationRules = array_filter ( $ this -> field -> validationRules , function ( $ rule ) { return $ rule != 'required' ; } ) ; } return $ this ; }
If the field is not visible on the form view, clear the validation.

@return $this
If the field is not visible on the form view clear the validation .