public function validate()
    {
        $report = common_report_Report::createInfo();

        foreach ($this->formProperties as $property) {

            try {
                $value = $property['formValue'];

                if (isset($property['validators'])) {
                    foreach ($property['validators'] as $validatorName) {
                        $validatorClass = 'tao_helpers_form_validators_' . $validatorName;
                        if (!class_exists($validatorClass)) {
                            throw new common_Exception('Validator is not correctly set (unknown)');
                        }
                        /** @var ValidatorInterface $validator */
                        $validator = new $validatorClass();
                        if (!$validator->evaluate($value)) {
                            throw new common_exception_ValidationFailed(
                                $property['uri'], $validator->getMessage()
                            );
                        }
                    }
                }

                if (isset($property['range'])) {
                    if (!isset($this->ranges[$property['range']])) {
                        throw new common_Exception($property['label'] . ' : Range is unknown');
                    }
                    $rangeValidated = false;
                    foreach ($this->ranges[$property['range']] as $rangeData) {

                        if (is_array($value)) {
                            foreach ($value as $k => $v) {
                                if ($rangeData['uri'] == $v) {
                                    unset($value[$k]);
                                }
                            }
                            if (empty($value)) {
                                $rangeValidated = true;
                                break;
                            }
                        } else {
                            if ($rangeData['uri'] == $value) {
                                $rangeValidated = true;
                                break;
                            }
                        }

                    }
                    if (!$rangeValidated) {
                        throw new common_exception_ValidationFailed(
                            $property['uri'], 'Range "' . $value . '" for field "' . $property['label'] . '" is not recognized.'
                        );
                    }

                }
            } catch (common_exception_ValidationFailed $e) {
                $subReport = common_report_Report::createFailure($e->getMessage());
                $subReport->setData($property['uri']);
                $report->add($subReport);
            }
        }

        return $report;
    }
public function validate()
    {
        $report = common_report_Report::createInfo();

        foreach ($this->formProperties as $property) {

            try {
                $value = $property['formValue'];

                if (isset($property['validators'])) {
                    foreach ($property['validators'] as $validatorName) {
                        $validatorClass = 'tao_helpers_form_validators_' . $validatorName;
                        if (!class_exists($validatorClass)) {
                            throw new common_Exception('Validator is not correctly set (unknown)');
                        }
                        /** @var ValidatorInterface $validator */
                        $validator = new $validatorClass();
                        if (!$validator->evaluate($value)) {
                            throw new common_exception_ValidationFailed(
                                $property['uri'], $validator->getMessage()
                            );
                        }
                    }
                }

                if (isset($property['range'])) {
                    if (!isset($this->ranges[$property['range']])) {
                        throw new common_Exception($property['label'] . ' : Range is unknown');
                    }
                    $rangeValidated = false;
                    foreach ($this->ranges[$property['range']] as $rangeData) {

                        if (is_array($value)) {
                            foreach ($value as $k => $v) {
                                if ($rangeData['uri'] == $v) {
                                    unset($value[$k]);
                                }
                            }
                            if (empty($value)) {
                                $rangeValidated = true;
                                break;
                            }
                        } else {
                            if ($rangeData['uri'] == $value) {
                                $rangeValidated = true;
                                break;
                            }
                        }

                    }
                    if (!$rangeValidated) {
                        throw new common_exception_ValidationFailed(
                            $property['uri'], 'Range "' . $value . '" for field "' . $property['label'] . '" is not recognized.'
                        );
                    }

                }
            } catch (common_exception_ValidationFailed $e) {
                $subReport = common_report_Report::createFailure($e->getMessage());
                $subReport->setData($property['uri']);
                $report->add($subReport);
            }
        }

        return $report;
    }
public function validate ( ) { $ report = common_report_Report :: createInfo ( ) ; foreach ( $ this -> formProperties as $ property ) { try { $ value = $ property [ 'formValue' ] ; if ( isset ( $ property [ 'validators' ] ) ) { foreach ( $ property [ 'validators' ] as $ validatorName ) { $ validatorClass = 'tao_helpers_form_validators_' . $ validatorName ; if ( ! class_exists ( $ validatorClass ) ) { throw new common_Exception ( 'Validator is not correctly set (unknown)' ) ; } /** @var ValidatorInterface $validator */ $ validator = new $ validatorClass ( ) ; if ( ! $ validator -> evaluate ( $ value ) ) { throw new common_exception_ValidationFailed ( $ property [ 'uri' ] , $ validator -> getMessage ( ) ) ; } } } if ( isset ( $ property [ 'range' ] ) ) { if ( ! isset ( $ this -> ranges [ $ property [ 'range' ] ] ) ) { throw new common_Exception ( $ property [ 'label' ] . ' : Range is unknown' ) ; } $ rangeValidated = false ; foreach ( $ this -> ranges [ $ property [ 'range' ] ] as $ rangeData ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { if ( $ rangeData [ 'uri' ] == $ v ) { unset ( $ value [ $ k ] ) ; } } if ( empty ( $ value ) ) { $ rangeValidated = true ; break ; } } else { if ( $ rangeData [ 'uri' ] == $ value ) { $ rangeValidated = true ; break ; } } } if ( ! $ rangeValidated ) { throw new common_exception_ValidationFailed ( $ property [ 'uri' ] , 'Range "' . $ value . '" for field "' . $ property [ 'label' ] . '" is not recognized.' ) ; } } } catch ( common_exception_ValidationFailed $ e ) { $ subReport = common_report_Report :: createFailure ( $ e -> getMessage ( ) ) ; $ subReport -> setData ( $ property [ 'uri' ] ) ; $ report -> add ( $ subReport ) ; } } return $ report ; }
Validate the form against the property validators.
In case of range, check if value belong to associated ranges list
Return failure report if one or more field is invalid

@return common_report_Report
@throws common_Exception In case of runtime error
Validate the form against the property validators . In case of range check if value belong to associated ranges list Return failure report if one or more field is invalid