Skip to content

Identity age validation#1632

Merged
Kenshiin13 merged 9 commits intoesx-framework:devfrom
Zykem:identity-age-validation
May 20, 2025
Merged

Identity age validation#1632
Kenshiin13 merged 9 commits intoesx-framework:devfrom
Zykem:identity-age-validation

Conversation

@Zykem
Copy link
Copy Markdown
Contributor

@Zykem Zykem commented Apr 28, 2025

Description

This PR refactors the age validation logic. It replaces the previous LowestYear and HighestYear with MinAge and MaxAge, making the age validation more dynamic and easier to configure. The logic now calculates the minimum and maximum valid birth years based on the current year and the configured MinAge and MaxAge.


Motivation

This PR was inspired by #1626 Pull Request, where a recent change only adjusted the MinYear configuration value. Rather than continuing with static year values, I aimed to provide a more flexible solution by introducing age-based configuration. This allows users to specify the age range directly, making it clearer and easier to manage, especially when maintaining the age validation across multiple versions.


Implementation Details

  • The Config.LowestYear and Config.HighestYear have been replaced by Config.MinAge and Config.MaxAge in the main config file.
  • The checkDOBFormat function has been updated to dynamically calculate the valid birth years based on the current year and the configured MinAge and MaxAge
  • A simplified leap year check has been incorporated to ensure that 29.02 (Feb. 29) is validated properly for leap years (instead of having this unreadable logic in the same function)

This refactor improves clarity, flexbility and scalability, allowing the age range to be updated without changing hardcoded year values.

Usage Example

Config.MinAge = 15
Config.MaxAge = 45

Now, instead of adjusting the LowestYear and HighestYear, users can directly specify the minimum and maximum ages.

PR Checklist

  • [] My commit messages and PR title follow the Conventional Commits standard.
  • [] My changes have been tested locally and function as expected.
  • [] My PR does not introduce any breaking changes.
  • [] I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@github-project-automation github-project-automation bot moved this to 🆕 To be Discussed in ESX Roadmap Apr 28, 2025
@Zykem Zykem requested a review from Mycroft-Studios April 28, 2025 16:53
@github-project-automation github-project-automation bot moved this from 🆕 To be Discussed to In-Development in ESX Roadmap May 20, 2025
Copy link
Copy Markdown
Contributor

@Kenshiin13 Kenshiin13 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@github-project-automation github-project-automation bot moved this from In-Development to Ready for Next Update in ESX Roadmap May 20, 2025
@Kenshiin13 Kenshiin13 merged commit 44805ad into esx-framework:dev May 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Next Update

Development

Successfully merging this pull request may close these issues.

3 participants