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

feat: support generating custom cast error message with a function #13608

Merged
merged 4 commits into from
Jul 14, 2023

Conversation

vkarpov15
Copy link
Collaborator

@vkarpov15 vkarpov15 commented Jul 12, 2023

Fix #3162

Summary

We do already have support for custom error messages, but that is using strings with template variables, like cast: '{VALUE} is not a number'.

With this PR, we'll also support "cast: [null, value => ${value} is not a number]" as a supported syntax to create a custom error message.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but documentation about this being possible is missing

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

test/docs/validation.test.js Show resolved Hide resolved
@vkarpov15 vkarpov15 merged commit c9e8861 into 7.4 Jul 14, 2023
38 of 39 checks passed
@vkarpov15 vkarpov15 added this to the 7.4.0 milestone Jul 14, 2023
@hasezoey hasezoey deleted the vkarpov15/gh-3162 branch July 14, 2023 20:16
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

Successfully merging this pull request may close these issues.

None yet

3 participants