Skip to content

Require complete hexadecimal color values - #145

Open
OskarEichler wants to merge 1 commit into
ku1ik:masterfrom
OskarEichler:codex/rainbow-hex-validation
Open

Require complete hexadecimal color values#145
OskarEichler wants to merge 1 commit into
ku1ik:masterfrom
OskarEichler:codex/rainbow-hex-validation

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Require hexadecimal RGB colors to contain exactly six hexadecimal digits, with the existing optional # prefix.

Reproduction

Current master accepts FF0000tail, a leading newline followed by FF0000, and a trailing newline. The leading-newline case is especially inconsistent: the regexp matches the second line while parsing still starts at byte zero, producing [15, 240, 0].

\A and \z make validation cover the complete input, matching the documented six-digit examples.

Verification

  • Existing suite: 220 examples, 0 failures on Ruby 3.2.11 and 4.0.6.
  • RuboCop: 15 files, 0 offenses on both Rubies.
  • External model: 2,082 checks per Ruby covering case/prefix combinations across 512 RGB values plus malformed prefixes, suffixes, whitespace, newlines, NUL and invalid digits.
  • Rebuilt gem: 14 expected files and successful packaged loads on both Rubies.
  • No test files changed.

Breaking change

Invalid strings that previously had a valid six-digit prefix are now rejected with ArgumentError. Valid documented inputs are unchanged.

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.

1 participant