Skip to content

Conversation

@lucalbus
Copy link

@lucalbus lucalbus commented Nov 7, 2025

Allow for negative years in publication date field, with a regexp allowing for a "-" in the beginning, and 0 to four digits.

While typing, the intial "-" is allowed before typing the other digits. If the data is sent withtout the digits (only a "-" as date), the controller applies tryParse which returns null in this case and therefore "-" cannot be saved as a date even if the input is possible first.

@lucalbus lucalbus changed the title Allow for negative years feat: Allow for negative years Nov 7, 2025
@RomanKovtyukh
Copy link

While typing, the intial "-" is allowed before typing the other digits. If the data is sent withtout the digits (only a "-" as date), the controller applies tryParse which returns null in this case and therefore "-" cannot be saved as a date even if the input is possible first.

Can we avoid this situation on regex level? Having \d{1,4} in the regex will make user type at least one digit.

https://regex101.com/r/XbQx9m/1

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