-
Notifications
You must be signed in to change notification settings - Fork 9
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
Validating A levels when publishing for teacher degree apprenticeship courses #4339
Validating A levels when publishing for teacher degree apprenticeship courses #4339
Conversation
We need to add a validation for the A levels when publishing a course. I added the option render_errors: with default being true to avoid breaking existing code but passing false to A levels Because: * The A levels are a multi step form and I need to inject the error on the row in any way is described in the card * The row has the wizard step name attached to the link so different from the way GCSEs or degrees or others are doing when publishing
if fields.any? { |field| @errors&.key? field.to_sym } | ||
errors = fields.map do |field| | ||
@errors[field.to_sym]&.map { |error| enrichment_error_link(model, field, error) } | ||
end.flatten | ||
|
||
value = raw(*errors) | ||
value = raw(*errors) if render_errors.present? |
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.
Avoiding the automatic behaviour because on the row, the error message is slightly different on A level since the A levels is the only multi step form in the course description tab. Unfortunately I have to do this to follow the same pattern but avoiding undesirable results.
|
||
return record.errors.add(:accept_pending_a_level, :blank) if record.accept_pending_a_level.nil? | ||
|
||
record.errors.add(:accept_a_level_equivalency, :blank) if record.accept_a_level_equivalency.nil? |
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 validations are sequential (meaning one at a time), so I opt-in to add a custom validator.
If you click on the error and goes to the wizard the back links are like if you're navigating within the wizard. I will leave as it is and wait for tomorrow bug party and I will talk with the designer about it. |
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.
Tested locally and everything works as expected. nice work!
thank you @elceebee , I appreciate 🙏 |
Context
We need to add a validation for the A levels when publishing a course.
Trello card & Lucid board
https://trello.com/c/BzbwKssS/1895-a-level-validation-when-publishing-a-course
https://lucid.app/lucidspark/ba759696-865b-46b4-ab23-9d3af92d79fb/edit?view_items=ohfKW2nmrz23&invitationId=inv_fa1f4bfe-7a1f-49d1-ae9c-1e46971e8f85
Changes proposed in this pull request
Please see trello card AND the lucid board for more details.
Guidance to review
I added the option render_errors: with default being true to avoid breaking existing code but passing false to A levels Because: