Model/DocumentService.php
/**
     * Validate a document using symfony validator
     * @param  Document $document The file to validate
     * @return boolean            True if the validation didn't raise any exception
     * @throws DocumentException  If the validation fails
     */
Validate a document using symfony validator
@param  Document $document The file to validate
@return boolean            True if the validation didn't raise any exception
@throws DocumentException  If the validation fails
Validate a document using symfony validator @param Document $document The file to validate @return boolean True if the validation didn ' t raise any exception @throws DocumentException If the validation fails
public function validate(Document $document)
    {
        $violations = $this->container->get('validator')->validate($document);
        if(count($violations) > 0) {
            $errors = [];
            foreach ($violations as $key => $violation) {
                $errors[] = $violation->getMessage();
            }
            throw new DocumentException($errors, "Error Validating Document : ".implode(',', $errors), 400);
        }
        return true;
    }
public function validate ( Document $ document ) { $ violations = $ this -> container -> get ( 'validator' ) -> validate ( $ document ) ; if ( count ( $ violations ) > 0 ) { $ errors = [ ] ; foreach ( $ violations as $ key => $ violation ) { $ errors [ ] = $ violation -> getMessage ( ) ; } throw new DocumentException ( $ errors , " Error Validating Document :  " . implode ( ',' , $ errors ) , 400 ) ; } return true ; }
Validate a document using symfony validator
 @param  Document $document The file to validate
 @return boolean            True if the validation didn't raise any exception
 @throws DocumentException  If the validation fails
Validate a document using symfony validator @param Document $document The file to validate @return boolean True if the validation didn ' t raise any exception @throws DocumentException If the validation fails