Skip to content

Dp 2398 tind spread validate header#43

Merged
davezuckerman merged 4 commits intomainfrom
DP-2398-tind-spread-validate-header
Apr 20, 2026
Merged

Dp 2398 tind spread validate header#43
davezuckerman merged 4 commits intomainfrom
DP-2398-tind-spread-validate-header

Conversation

@davezuckerman
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@steve-sullivan steve-sullivan left a comment

Choose a reason for hiding this comment

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

Overall looks good... I only have that one question regarding the regex, but not sure it's even necessary.

Comment thread app/lib/tind_spread/tind_validation.rb Outdated

# validates the header rown
def self.valid_header?(str)
str.match?(/\d{3}[_|\d]{2}[a-zA-Z0-9]$/) || str.match?(/\d{3}[_|\d]{2}[a-zA-Z0-9]-\d$/) || str.match?(/Filename|FFT/i)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might want to elaborate on the comment (include examples of what the REGEX is matching there)

I'm not 100% sure, I'm rusty w/regular expressions, but is the first 1s match necessary? Could this be slightly simplified by removing the first match and change the 2nd match by wrapping the -d in parens and adding a '?' after it?
example: ...a-zA-Z0-9?$/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point about the comments. Just added some more.

For the reg expression having a ? at the end would work but be too permissive. The option (-1) has to be a dash followed by a number

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so (-\d)? wouldn't work....?

Copy link
Copy Markdown
Contributor Author

@davezuckerman davezuckerman Apr 20, 2026

Choose a reason for hiding this comment

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

Actually if I add a "$" after the ? looks like it works.
"/\d{3}[_|\d]{2}a-zA-Z0-9?$/)"

I'll change the expression

@davezuckerman davezuckerman merged commit c7871d1 into main Apr 20, 2026
5 checks passed
@davezuckerman davezuckerman deleted the DP-2398-tind-spread-validate-header branch April 20, 2026 22:23
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