Skip to content
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

Added name argument to validators for ticket validations #10572

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

danieljames-dj
Copy link
Member

One drawback of this is still js cannot replace "%{name}" with name. So, this doesn't fix the UI issue. This should be solved when moved to i18n. This PR aims at sending name parameter for dob_validations method.

@@ -41,22 +41,22 @@ def include_persons?
true
end

def self.dob_validations(dob, competition_id = nil, name = nil)
def self.dob_validations(dob, message_args = {}, competition_id = nil)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can make it more Ruby-esque by something like...

Suggested change
def self.dob_validations(dob, message_args = {}, competition_id = nil)
def self.dob_validations(dob, competition_id = nil, **message_args)

Copy link
Member

Choose a reason for hiding this comment

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

If you take this suggestion, then below you can "spread" the parameters into the ValidationIssue class as well: ValidationWarning.new(:persons, competition_id, DOB_0101_WARNING, **message_args)

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay done.

@@ -101,7 +101,7 @@ def run_validation(validator_data)
name: p.name)
end

PersonsValidator.dob_validations(p.dob, competition.id, p.name).each do |validation|
PersonsValidator.dob_validations(p.dob, { name: p.name }, competition.id).each do |validation|
Copy link
Member

Choose a reason for hiding this comment

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

For my suggestion above, this could be changed to PersonsValidator.dob_validations(p.dob, competition.id, name: p.name)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -49,7 +49,7 @@ def edit_person_validators
ticket.metadata.tickets_edit_person_fields.each do |edit_person_field|
case edit_person_field[:field_name]
when TicketsEditPersonField.field_names[:dob]
dob_validation_issues = ResultsValidators::PersonsValidator.dob_validations(Date.parse(edit_person_field[:new_value]))
dob_validation_issues = ResultsValidators::PersonsValidator.dob_validations(Date.parse(edit_person_field[:new_value]), { name: ticket.metadata.wca_id })
Copy link
Member

Choose a reason for hiding this comment

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

If you like my other suggestion about the method signature, then this can become...

Suggested change
dob_validation_issues = ResultsValidators::PersonsValidator.dob_validations(Date.parse(edit_person_field[:new_value]), { name: ticket.metadata.wca_id })
dob_validation_issues = ResultsValidators::PersonsValidator.dob_validations(Date.parse(edit_person_field[:new_value]), name: ticket.metadata.wca_id)

Copy link
Member

Choose a reason for hiding this comment

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

Sidenote: You should probably extract the Date.parse into its own line, helps with debugging :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@danieljames-dj danieljames-dj merged commit 12c33cb into thewca:main Jan 13, 2025
2 checks passed
@danieljames-dj danieljames-dj deleted the validators-params branch January 13, 2025 02:54
FinnIckler added a commit to FinnIckler/worldcubeassociation.org that referenced this pull request Jan 14, 2025
create seperate index for filters

implement backend loading and filters

remove segment

fix stylings in filters

fix gender and region not being filtered

added show filters

implement by regions table

add i18n to resultsfilter

Create can_user_access? for ticket (thewca#10570)

* Create can_user_access? for ticket

* Review changes

Update sv translation.

Check competition dates for upcoming comps while banning (thewca#10573)

Edit Person Requests page in WRT panel (thewca#10451)

* Edit Person Requests page in WRT panel

* Review changes

---------

Co-authored-by: Daniel M James <[email protected]>

Remove @@character_set_server latin1 check (thewca#10584)

* Remove @@character_set_server latin1 check

* change check for utf8mb4

Switch flag to disable Comp Overview React on demand (thewca#10577)

* Switch flag to disable Comp Overview React on demand

* Fix tests

Bump @cubing/icons from 1.1.3 to 2.0.2

Bumps [@cubing/icons](https://github.com/cubing/icons) from 1.1.3 to 2.0.2.
- [Release notes](https://github.com/cubing/icons/releases)
- [Commits](cubing/icons@v1.1.3...v2.0.2)

---
updated-dependencies:
- dependency-name: "@cubing/icons"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Only disable qualification button if qualifications are enforced (thewca#10598)

* only disable qualification button if qualifications are enforced

* removed logs

Date Range locale fixes (thewca#10599)

* export time_will_tell i18n

* translate date_range function from time will tell

* use dateRange function in my competitions and competition overview

* make luxon use the I18n locale in the i18n string

* just use luxon Interval

* fix rubocop

Update pt translation.

Added name argument to validators for ticket validations (thewca#10572)

* Added name argument to validators for ticket validations

* Review changes

Bump @stripe/stripe-js from 5.4.0 to 5.5.0

Bumps [@stripe/stripe-js](https://github.com/stripe/stripe-js) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/stripe/stripe-js/releases)
- [Commits](stripe/stripe-js@v5.4.0...v5.5.0)

---
updated-dependencies:
- dependency-name: "@stripe/stripe-js"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump stylelint from 16.12.0 to 16.13.0

Bumps [stylelint](https://github.com/stylelint/stylelint) from 16.12.0 to 16.13.0.
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](stylelint/stylelint@16.12.0...16.13.0)

---
updated-dependencies:
- dependency-name: stylelint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump glob from 11.0.0 to 11.0.1

Bumps [glob](https://github.com/isaacs/node-glob) from 11.0.0 to 11.0.1.
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](isaacs/node-glob@v11.0.0...v11.0.1)

---
updated-dependencies:
- dependency-name: glob
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump eslint-plugin-react from 7.37.3 to 7.37.4

Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.37.3 to 7.37.4.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](jsx-eslint/eslint-plugin-react@v7.37.3...v7.37.4)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump aws-sdk-rds from 1.264.0 to 1.265.0

Bumps [aws-sdk-rds](https://github.com/aws/aws-sdk-ruby) from 1.264.0 to 1.265.0.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-rds/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-rds
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Fix typo (thewca#10606)

Remove side effect from const & simplify/rename (thewca#10597)

Move WFC panel to default panel (thewca#10583)

Fix Person trying to serialize non-existing methods in User (thewca#10575)

* Fix Person trying to serialize non-existing methods in User

* Stringify keys upon merge

* Allow serializing teams through Person (grrr)

* Refactor serialization defaults to respect tests

Circumvent cache in WIC->Ethics sync (thewca#10588)

Bump @tanstack/react-query from 5.62.15 to 5.64.0

Bumps [@tanstack/react-query](https://github.com/TanStack/query/tree/HEAD/packages/react-query) from 5.62.15 to 5.64.0.
- [Release notes](https://github.com/TanStack/query/releases)
- [Commits](https://github.com/TanStack/query/commits/v5.64.0/packages/react-query)

---
updated-dependencies:
- dependency-name: "@tanstack/react-query"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump rubocop from 1.69.2 to 1.70.0 (thewca#10608)

Replace redirect with panel-page (thewca#10585)

Migrate mysql to 8.4 in Docker compose (thewca#10548)

* update docker compose for mysql8.4

* remove deprecated command

Let dropdowns expand beyond Modal body in EditEvents (thewca#10544)

* Let dropdowns expand beyond Modal body in EditEvents

* Let each individual modal choose whether they want scrolling

Hotfix: Allow mysql_native plugin locally as grace period

Run yarn dedupe after dependency updates

fix competitions_by_id serialization

don't include organizers or delegates in competition serialization

fix indentation

fix country being imported in routes

Update app/webpacker/components/Results/resultsFilter.jsx

Co-authored-by: Kevin Matthews <[email protected]>

mobile changes

Update app/webpacker/components/Results/Rankings/RankingsTable.jsx

Co-authored-by: Kevin Matthews <[email protected]>

change useMemo to try and fix by region rendering

force Table Body to rerender when changing show modes

use reduce instead of map

use a reducer instead of state

add title prop

parse initial State from the URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants