E_VALIDATION_FAILED: Validation failed

#1

Just upgraded from 4.0 to 4.1

I have a simple route validator on POST. In validator file I have rules() messages()

'use strict'

class RegistrationValidation {

  get sanitizationRules () {
    return {
      email:  'normalize_email'
    }
  }

  get rules () {
    return {
      username: 'required|min:4|max:15',
      email: 		'required|email|max:50|unique:users:email',
      password: 'required|min:6',
      password_confirmation: 'required_if:password|same:password'
    }
  }

  get messages () {
    return {
      required: '{{ field }} is required to register!',
      min: 			'{{ field }} is too short!',
      max:			'{{ field }} is too long!',
      unique:		'{{ field }} is used!',
      same :    'Password must match!'
    }
  }
}

module.exports = RegistrationValidation

and route:

Route.post('register', 'AuthController.register').validator('RegistrationValidation')

Anyway, before the upgrade worked fine,. In the view I fetched the errors array with

@if(old('errors'))
  @each(error in old('errors'))
  <div class="alert alert-danger alert-dismissable">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
      {{ error.message }}
  </div>
  @endeach
@endif

Now all I am getting is
E_VALIDATION_FAILED: Validation failed

What did I miss?

0 Likes

#2

Can you share the global exception handler code

0 Likes

#3

Hey @virk - I did check the upgrade docs again and indeed exception was missing the one pointed in the docs.

await super.handle(...arguments)

so now it is working again!

Thank you! :slight_smile:

0 Likes