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 number and boolean values in validation message "$value" tokens #1467

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

kffl
Copy link
Contributor

@kffl kffl commented Dec 27, 2021

Description

As reported in issues #921 and #1046, the $value token in validation message isn't replaced properly in some cases. It turns out that the $value token 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. to leave 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.

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

references #1046, references #921

@NoNameProvided
Copy link
Member

NoNameProvided commented Dec 3, 2022

Hi @kffl, can you please rebase or cherry pick this to the latest develop branch?

Edit: I have done if for you.

@NoNameProvided NoNameProvided changed the title fix: allow numbers and booleans as validation message "$value" tokens fix: allow number and boolean values in validation message "$value" tokens Dec 15, 2022
@NoNameProvided NoNameProvided merged commit d325cc7 into typestack:develop Dec 15, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants