-
Notifications
You must be signed in to change notification settings - Fork 3
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
DDLS-426 : Prevent user from inputting invalid year during registration #1781
base: main
Are you sure you want to change the base?
Conversation
client/app/src/Form/ClientType.php
Outdated
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { | ||
$data = $event->getData(); | ||
$data['firstname'] = strip_tags($data['firstname']); | ||
$data['lastname'] = strip_tags($data['lastname']); | ||
$event->setData($data); | ||
|
||
if (!preg_match('/^\d{4}$/', $data['courtDate']['year'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move this to some form validation rather than here. Also should complete a check that's not in the future. Maybe also too far in the past, not sure there is any valid cases in the 1800's
|
||
->add('save', FormTypes\SubmitType::class); | ||
if (!preg_match('/^\d{4}$/', $data['startDate']['year']) || !preg_match('/^\d{4}$/', $data['endDate']['year'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, as well
Purpose
Following investigation into a bug that prevented a document from syncing to Sirius, it appears that a user can enter an invalid year when entering the court date and reporting period during the registration process.
It looks like Symony's form component attempts to transform an invalid date into a valid DateTime object based on the configured format of 'yyyy-MM-dd'. For example, a user's input of 13-12-25 transforms into '0013-12-25' and is stored in the database.
This only seems to affect the year as validation is thrown when inputting invalid dates and months.
Fixes DDLS-426
Approach
Learning
Any tips and tricks, blog posts or tools which helped you. Plus anything notable you've discovered about DigiDeps
Checklist
Frontend