-
Notifications
You must be signed in to change notification settings - Fork 186
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
Add ID to validation_issue #10521
Add ID to validation_issue #10521
Conversation
@@ -46,17 +46,17 @@ def self.dob_validations(dob, competition_id = nil, name = nil) | |||
|
|||
# Check if DOB is January 1 | |||
if dob.month == 1 && dob.day == 1 | |||
validation_issues << ValidationWarning.new(:persons, competition_id, DOB_0101_WARNING, name: name) | |||
validation_issues << ValidationWarning.new(:dob_jan_one, :persons, competition_id, DOB_0101_WARNING, name: name) |
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.
@gregorbg This is my initial plan for adding IDs. I think it will be better if the IDs are fetched from an enum-like object instead of directly adding the ID here. What do you think?
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.
Well, what exactly are you suggesting? I mean, the idea sounds nice, so what kind of "enum-like" structure are you thinking about?
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.
I've implemented that - I feel that is more easier than typing. Can you please check the implementation now? Can I go ahead with the same for all definitions or do you have any feedbacks before making change in other definitions?
876cab1
to
af0c4cd
Compare
VALIDATION_TYPES = VALIDATION_TYPES_KEYS.each_with_object({}) do |key, hash| | ||
hash[key] = key.to_s | ||
end.freeze |
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.
I am definitely sure that I told you this trick before, but I'll tell you again:
my_list.index_with { |list_elem| list_elem.to_s }
or even shorter my_list.index_with(&:to_s)
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.
Yes, I remember you said the trick, but I didn't remembered it from top of my head so just went ahead with copilot suggestion for time being. Truly I had plan to optimize it later.
Thanks for giving the shorthand again, I've added them now.
af0c4cd
to
fc73a30
Compare
@gregorbg Can you please let me know if this aligns with what we discussed? If yes, can I go ahead with making these changes in the other initializations? |
fc73a30
to
75451a1
Compare
@@ -18,7 +19,7 @@ function EditPersonValidations({ ticketDetails }) { | |||
if (error) return <Errored />; | |||
|
|||
return validators.dob.map((validator) => ( | |||
<Message warning>{validator.message}</Message> | |||
<Message warning>{I18n.t(`validators.person.${validator.id}`)}</Message> |
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.
This will not fill the i18n keys correctly, I'm afraid
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.
I.e. the message will look like "The date of birth of [missing 'name' param] is on January 1st"
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.
Yes, actually the same error is there in production as well. Since this is internal to WRT, I thought of adjusting with this error because knowing 'something is wrong' is better than knowing nothing.
TBH I didn't spend time to check if name can be populated here. I guess it should be possible through ticketDetails. I'll explore if that is possible.
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.
I just checked and WCA ID is available. For now I have added WCA ID. But I feel this fix should be separate PR, I'll do that later. For now I've added it in this PR, will change later.
@kind = kind | ||
@args = message_args | ||
@competition_id = competition_id | ||
end | ||
|
||
def to_s | ||
format(@message, @args) | ||
I18n.t("validators.person.#{@id}", **@args) |
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.
I think you need to include @kind
in this message instead of hard-coding person
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.
Oh yes, changed.
0a39b98
to
188fb17
Compare
188fb17
to
2d1eb01
Compare
2d1eb01
to
0b75f04
Compare
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.
The structure and concept is totally fine by me. I haven't reviewed all individual copy-paste operations though, perhaps a second WRT member could make sure you haven't accidentally swapped any validation messages?
Sure, I'll ask WRT to do it. |
@thewca-bot deploy staging |
Currently there is no identifier for validation issue, this PR aims in adding ID so that this will help in many future features.