Skip to content

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

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

Open
wants to merge 101 commits into
base: master
Choose a base branch
from

Conversation

kffl
Copy link

@kffl kffl commented Jan 7, 2022

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

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

Thanks for taking the time to create this fork. I have opened a PR with the same changes against the original repo, but given its rather stale maintenance status I thought that I might as well do it here.

I have also fixed formatting of the PR template file which was causing the CI pipeline to fail.

kamilmysliwiec and others added 30 commits October 28, 2021 09:37
chore(deps): update dependency @types/node to v14.17.32
…-11.x

chore(deps): update dependency @rollup/plugin-node-resolve to v11.2.1
chore(deps): update dependency lint-staged to v10.5.4
chore(deps): update dependency husky to v4.3.8
chore(deps): update dependency eslint to v7.32.0
chore(deps): update dependency rollup to v2.58.3
chore(deps): update dependency eslint-plugin-jest to v24.7.0
chore(deps): update dependency ts-jest to v26.5.6
renovate-bot and others added 28 commits November 1, 2021 11:06
chore(deps): update dependency validator to 13.7.0 [security]
Corrected npm install command - package name
Match file contents with the nestjs/nest/.github/PULL_REQUEST_TEMPLATE.md
style: update PR template markdown file
@kamilmysliwiec kamilmysliwiec force-pushed the master branch 2 times, most recently from 7b454dd to 5f0d424 Compare June 20, 2023 07:03
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.

5 participants