Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2022 23:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Laravel Vest Enforcer
// Laravel server error enforcer, allows for a Laravel validation error response to be passed in to validate with Vest.
// Fields should use the same name between server and client, currently the enforcer only reports the first error.
// In order to use, pass, function expects the following format
// {
// email: ['error message here', 'error message 2']
// password: ['Password is too weak']
// }
export default function hasServerError (value, field, serverErrors) {
if (Object.keys(serverErrors).indexOf(field) !== -1) {
return {
pass: false,
message: serverErrors[field][0]
return {
pass: true,
message: () => ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment