Skip to content

Add support for handling validation error messages

Pre-release
Pre-release
Compare
Choose a tag to compare
@thetutlage thetutlage released this 19 Jul 09:39

The ExceptionHandler class now contains special logic to handle validation errors and convert them to HTTP response using content negotiation.

The validation error message can come from any validation library as long as it has code and messages properties as per the following guidelines.

// Error code should be set
error.code = 'E_VALIDATION_ERROR'

// Error messages must be an array
error.messages = [
  {
     message: '',
     field: '',
     rule: ''
  }
]

Commits

  • test: improve assertions to work cross platform 1219602
  • chore: add missing dependency required for tests 2cd997e
  • feat(ExceptionHandler): separately hand validation error messages 76f6985
  • style: format source code ca7e409
  • chore: update dependencies 07020ce

Full Changelog: v6.8.2-8...v6.8.2-9