Skip to content

Conversation

@Gev1990123
Copy link
Collaborator

  • 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.

…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) }
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/]
Copy link
Collaborator

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

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}\?/
Copy link
Collaborator

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
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