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

fix: allow numbers and booleans as validation message "$value" tokens #2

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

burriedu2
Copy link
Owner

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

The $value token placed in the validation message is parsed as expected only when the provided value is of type string, which results in commonly used validators with non-string values such as @MinLength, @Min, @MaxLength, @Max ect. leaving the $value token in the validation message without replacing it. This PR relaxes the runtime typecheck performed when constructing the validation message by allowing types boolean and number (alongside string) to act as $value token replacements.

Documented in issues: typestack#921, typestack#1046, also reported in the NestJS repo as nestjs/nest#6431
Issue Number: N/A

What is the new behavior?

As documented in README examples - $value tokens will be replaced in the validation error message even if the underlying value is a number or a boolean.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@burriedu2 burriedu2 merged commit 49de47e into master Aug 10, 2023
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.

2 participants