Skip to content

fix: type date validation values as strings - #17860

Open
cbratschi wants to merge 1 commit into
payloadcms:mainfrom
cbratschi:fix/date-validation-string
Open

fix: type date validation values as strings#17860
cbratschi wants to merge 1 commit into
payloadcms:mainfrom
cbratschi:fix/date-validation-string

Conversation

@cbratschi

Copy link
Copy Markdown

What?

Corrects the DateFieldValidation input type from Date to the serialized string value passed to date validators. Also removes the unnecessary string conversion before parsing and adds a type-level regression test.

Why?

Payload date fields are represented as strings in generated types and are passed to validation as strings at runtime. Typing validator values as Date makes custom date validators inconsistent with their actual input.

How?

  • Changes the DateFieldValidation value generic to string
  • Parses the string value directly
  • Asserts the public validation input type with TSTyche

Fixes #10605

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.

Date field: string vs. Date types

1 participant