Skip to content

Accept signed int32 colors in validator#7

Merged
cowboyd merged 2 commits into
mainfrom
validate-colors
Apr 8, 2026
Merged

Accept signed int32 colors in validator#7
cowboyd merged 2 commits into
mainfrom
validate-colors

Conversation

@cowboyd

@cowboyd cowboyd commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The rgba() helper returns a signed int32 when alpha >= 128 (bit 31 is set via (a & 0xFF) << 24). JavaScript interprets this as a negative number. The validator's u32 type (minimum: 0) rejects these values, causing validated() to throw on any color with full alpha — which is the default.

Approach

Add a color type that accepts the full range from -0x80000000 to 0xFFFFFFFF and use it for bg, border.color, and text color fields. The underlying bit pattern is identical; the validator just needs to accept both signed and unsigned interpretations.

Test plan

  • Existing validate tests pass
  • validated() accepts ops with rgba(40, 42, 54) (negative int32) without throwing

The rgba() function returns signed int32 when alpha >= 128 (bit 31
set). The validator's u32 type rejected these negative values. Add
a color type that accepts the full signed-to-unsigned 32-bit range.
@pkg-pr-new

pkg-pr-new Bot commented Apr 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/clayterm@7

commit: 92577d4

The rgba() function returns signed int32 when alpha >= 128 (bit 31
set). The validator's u32 type rejected these negative values. Add
a color type that accepts the full signed-to-unsigned 32-bit range.
@cowboyd cowboyd merged commit d402924 into main Apr 8, 2026
5 checks passed
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