Skip to content

feat(service): add hex_color and iso_date_only validators - #23

Merged
ATLURI0001 merged 1 commit into
mainfrom
feat/service-hex-color-and-date-only-validators
Nov 16, 2026
Merged

ATLURI0001 merged 1 commit into
mainfrom
feat/service-hex-color-and-date-only-validators

Conversation

@ATLURI0001

Copy link
Copy Markdown
Owner

Overview

  • Extends LMS backend HTTP parameter validation layer with dedicated validation rules for UI hexadecimal color tokens and ISO-8601 calendar dates (YYYY-MM-DD).
  • Eliminates boilerplate regex routines across course themes, user profile branding, and assignment deadline parsers.

Key Technical Updates

  • Hex Color Validator (hex_color):
    • Enforces valid 3, 4, 6, or 8-digit #RGB, #RGBA, #RRGGBB, #RRGGBBAA CSS hex color formats via regex: ^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$.
    • Sanitizes and normalizes output into lowercased strings.
    • Supports required=False with clean default fallback to "".
  • Calendar Date Validator (iso_date_only):
    • Validates date strings formatted strictly as YYYY-MM-DD.
    • Incorporates real Gregorian calendar validation via datetime.date.fromisoformat(val) to reject impossible calendar dates (such as 2026-02-31).
    • Emits consistent HTTP 422 ApiError with explicit error descriptions.

Verification & Test Results

  • Backend Test Suite: uv run pytest -o pythonpath="." tests/test_service_validation.py
  • Test Outcome: 13 / 13 tests passed in 0.08s
  • Test Coverage:
    • Tested 3, 6, and 8-digit hex codes, missing hash prefixes, non-hex characters, and 5-digit invalid lengths.
    • Tested valid ISO calendar dates, month/day overflow checks, slash delimiter rejection, and optional field fallbacks.

Impact Analysis

  • No regressions across existing text, integer, boolean, url, email, uuid, or slug validators.
  • Centralizes theme and deadline validation logic into reusable service primitives.

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lmskl Error Error Nov 16, 2026 4:50am UTC

@ATLURI0001
ATLURI0001 merged commit c3039ba into main Nov 16, 2026
6 of 8 checks passed
@ATLURI0001
ATLURI0001 deleted the feat/service-hex-color-and-date-only-validators branch November 16, 2026 04:50

This branch had an error being deployed

1 failed deployment
Preview — ca262e29 Deployed Nov 16, 2026 by vercel[bot]
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