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

Validate course number #318

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

simfeld
Copy link
Contributor

@simfeld simfeld commented Mar 9, 2024

No description provided.

@@ -13,6 +13,8 @@ module Pbs::Event::Course
APPROVALS = %w(requires_approval_abteilung requires_approval_region
requires_approval_kantonalverband requires_approval_bund).freeze

COURSE_NUMBER_REGEX = /\APBS CH(?: [A-Z]{2})? [0-9]{3}-[0-9]{2}\z/.freeze
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following what's specified in https://pilot.scouts.ch (page 12 in the current version)

if: :validate_number? }

def validate_number?
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_number
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be possible to update existing records as long as course number and event kind are left untouched

@simfeld simfeld force-pushed the feature/validate-course-number branch from 578d877 to 7201c7c Compare March 9, 2024 22:37
Copy link
Member

@TheWalkingLeek TheWalkingLeek left a comment

Choose a reason for hiding this comment

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

Schaut gut aus!
Habs jetzt noch nicht manuell getestet & wäre sicher super wenn der CI durchlaufen würde. Als Tipp hilft hoffentlich mein Kommentar bei der Migration :)

if: :validate_number? }

def validate_number?
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_number
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_number
return false unless kind.validate_course_number?
new_record? ||
number_changed? ||
kind_id_changed?

Find ich persönlich leserlicher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants