Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for verbose error details #4

Open
rrojan opened this issue Jun 16, 2023 · 0 comments
Open

Add support for verbose error details #4

rrojan opened this issue Jun 16, 2023 · 0 comments

Comments

@rrojan
Copy link
Owner

rrojan commented Jun 16, 2023

Normally we have errors like

[]string{
    "Required field 'Name' is not provided",
    "Age must be greater than 18"
}

However this does not support custom error messages.

Providing "resourceType" and "failed" allows us to create custom error messages, both on the frontend and backend.

[]enforcer.Failed {
    enforcer.Failed{
        ResourceType: "name",
        Failed: "required",
    },
    enforcer.Failed{
        ResourceType: "age",
        Failed: "min:18",
    },
}

Then you can create custom error messages for any language like

// utils/generateErrorMessage.js


function generateErrorMessage(resource, failed) {
    return "Appropriate error from failed"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant