Skip to content

fix: allow number and boolean values in validation message "$value" tokens - #1467

Merged
NoNameProvided merged 1 commit into
typestack:developfrom
kffl:fix/message-value-parsing
Dec 15, 2022
Merged

NoNameProvided merged 1 commit into
typestack:developfrom
kffl:fix/message-value-parsing

Conversation

@kffl

@kffl kffl commented Dec 27, 2021 •

Copy link
Copy Markdown
Contributor

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

NoNameProvided commented Dec 3, 2022 •

Copy link
Copy Markdown
Member

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

Edit: I have done if for you.

@NoNameProvided
NoNameProvided force-pushed the fix/message-value-parsing branch from f71b2d8 to 53b7683 Compare December 3, 2022 14:21
@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
Copy Markdown

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.

3 participants