-
Notifications
You must be signed in to change notification settings - Fork 17
BugID-1364 #2847
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
base: master
Are you sure you want to change the base?
BugID-1364 #2847
Conversation
…s.rb Updated new_freereg_csv_update_processor.rb to use the new function to validate record date strings
- Updated VALID_DAY regex to /\A[\d_]{1,2}\z/ to properly restrict day values
to 1–2 digits or allowed wildcards. This prevents invalid inputs like '321 Jan 1807'
from being accepted.
- Updated VALID_YEAR regex to /\A\d{4}\z/ to allow only 4-digit years for the first
part of a split year. This clarifies the intent and removes misleading {4,5} repetition,
while preserving support for historical split-year formats (e.g., '1807/8') via check_year.
- Introduced `FreeregValidations.valid_record_date?` to validate individual record dates.
- Updated `process_baptism_data_fields`, `process_burial_data_fields`, and `process_marriage_data_fields` to call the new validation function for relevant date fields.
- Changed `VALID_DAY` regex to `/\A[\d_]{1,2}\z/` to reject invalid days like 321.
- Adjusted `VALID_YEAR` usage in `check_year` to ensure years are properly validated; corrected handling of split years (e.g., 1807/8) while allowing blanks.
- Ensures that invalid dates are recorded in `:date_errors` while blanks remain valid.
…A\d{3}[\*\_\?]\z/, /\A\d{2}__\z/, /\A\d{2}\*\z/]
- Updated method def self.check_year(yyyy), to include the above regexp group, in return true if VALID_YEAR_PATTERNS.any? { |re| yyyy.match?(re) }
lib/freereg_validations.rb
Outdated
| VALID_MONTH = %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec *].freeze | ||
| VALID_NUMERIC_MONTH = /\A\d{1,2}\z/ | ||
| VALID_YEAR = /\A\d{4}\z/ | ||
| VALID_YEAR_PATTERNS = [/\A\d{3}[\*\_\?]\z/, /\A\d{2}__\z/, /\A\d{2}\*\z/] |
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.
Sorry, I made a mistake here in the first pattern, which allows a date like 187? but prohibits a date like 1875? Split the first pattern into two patterns:
/\A\d{3}[\*\_]\z/ to allow 185* and 185_
/\A\d{4}\?\z/ to allow ? only if it follows 4 explicit numerals
lib/freereg_validations.rb
Outdated
| def self.check_year(yyyy) | ||
| return true if yyyy == '*' || yyyy =~ /\A\d{1,3}[\*_\?]\z/ || yyyy =~ /\A\d{4}\?\z/ | ||
| return true if VALID_YEAR_PATTERNS.any? { |re| yyyy.match?(re) } | ||
| #return true if yyyy == '*' || yyyy =~ /\d{2}\*/ || yyyy =~ /\d{3}_/ || yyyy =~ /\d{2}_{1}/ || yyyy =~ /\d{4}\?/ |
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 would delete this line rather than comment it out since git keeps the history for us
- fixed the year validation as per comment - removed the commented out code
Updated VALID_DAY regex to /\A[\d_]{1,2}\z/ to properly restrict day values
to 1–2 digits or allowed wildcards. This prevents invalid inputs like '321 Jan 1807'
from being accepted.
Updated VALID_YEAR regex to /\A\d{4}\z/ to allow only 4-digit years for the first
part of a split year. This clarifies the intent and removes misleading {4,5} repetition,
while preserving support for historical split-year formats (e.g., '1807/8') via check_year.