app/Validation/Validator.php
//loop through our validation rules to check for any errors and append any error messages
loop through our validation rules to check for any errors and append any error messages
loop through our validation rules to check for any errors and append any error messages
public function validate($request, array $rules)
  {
    foreach ($rules as $field => $rule) {
      try {
        $rule->setName(ucfirst($field))->assert($request->getParam($field));
      } catch (NestedValidationException $e) {
        $this->errors[$field] = $e->getMessages();
      }
    }
    $_SESSION['errors'] = $this->errors;
    return $this;
  }
public function validate ( $ request , array $ rules ) { foreach ( $ rules as $ field => $ rule ) { try { $ rule -> setName ( ucfirst ( $ field ) ) -> assert ( $ request -> getParam ( $ field ) ) ; } catch ( NestedValidationException $ e ) { $ this -> errors [ $ field ] = $ e -> getMessages ( ) ; } } $ _SESSION [ 'errors' ] = $ this -> errors ; return $ this ; }
loop through our validation rules to check for any errors and append any error messages
loop through our validation rules to check for any errors and append any error messages
//persisting our error data onto our views