Skip to content

Date validations to prevent invalid dates like 6/1/20000#5806

Merged
compwron merged 14 commits into
mainfrom
5646_invalid_dates
Jun 7, 2024
Merged

Date validations to prevent invalid dates like 6/1/20000#5806
compwron merged 14 commits into
mainfrom
5646_invalid_dates

Conversation

@marc
Copy link
Copy Markdown
Collaborator

@marc marc commented Jun 1, 2024

What github issue is this PR for, if any?

Resolves #5646

What changed, and why?

Added date validations to avoid bad dates like 6/1/20000:

CourtDate

  • date - no earlier than 1/1/1989. No later than 1 year in the future.
  • court_report_due_date - ignored

CasaCase

  • birth_month_year_youth —> range from 1989 to today
  • court_report_due_date —> ignored
  • court_report_submitted_at —> set by app
  • date_in_care —> range is from 1989 to today

CaseContact

  • occurred_at —> already validates can’t be in future, added 1989 minimum

LearningHour

  • occurred_at —> already validates can’t be in future, added 1989 minimum

MileageRate

  • effective_date —> no earlier than 1/1/1989. No later than 1 year in the future.

OtherDuties

  • occurred_at —> no earlier than 1/1/1989. No later than 1 year in the future.

PlacementsStartedAt

  • Placement_started_at —> no earlier than 1/1/1989. No later than 1 year in the future.

User

  • date_of_birth —> range from 1920 to today

UserReminderTime - added by #3735 but not used anywhere. Currently no orgs use SMS anyways so we are fine ignoring this
case_contact_types —> ignored
no_contact_made —> ignored

How is this tested? (please write tests!) 💖💪

Updated specs for models and manually tested UI.

Screenshots please :)

Sample validation for new court dates:
image

Feelings gif (optional)

😀 😀
Ruby for Good 2024! 😀 😀

Worked on by @yyelleww70 and @marc .

@marc marc added the Ruby for Good 2024 DC Ruby for Good 2024 DC event tickets label Jun 1, 2024
@compwron
Copy link
Copy Markdown
Collaborator

compwron commented Jun 1, 2024

looks great, please fix failing tests and then we can merge :)

Copy link
Copy Markdown
Collaborator

@elasticspoon elasticspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Just a thought (don't actually change anything in response to this) I wonder if a better arbitrary date instead of 1989 should have been 22 years ago (I think 21 years is the cap on age in foster care).

@compwron compwron merged commit 89e6a68 into main Jun 7, 2024
@compwron compwron deleted the 5646_invalid_dates branch June 7, 2024 16:58
@compwron
Copy link
Copy Markdown
Collaborator

compwron commented Jun 7, 2024

24 days cap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ruby for Good 2024 DC Ruby for Good 2024 DC event tickets ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: do not allow invalid dates

4 participants