Skip to content

feat(validator): implement payment-template-validator lib (Squad B)#6

Open
huandrey wants to merge 8 commits into
masterfrom
dojo-starter
Open

feat(validator): implement payment-template-validator lib (Squad B)#6
huandrey wants to merge 8 commits into
masterfrom
dojo-starter

Conversation

@huandrey

@huandrey huandrey commented Jun 2, 2026

Copy link
Copy Markdown

Summary

  • US-1 / US-3 — Extracted validation logic into a standalone lib at packages/validator/src/ exposing async validate(dir, opts) → {ok, errors}. The CLI at validator/cli.js is now a thin client that calls the lib.
  • US-2--json flag produces machine-readable output for CI pipelines; exit codes 0 (valid), 1 (validation errors), 2 (usage errors) are enforced.
  • 4 rules implemented: maxFileSize, i18nKeyConsistency, htmlSafety, noExternalRefs — all pluggable via packages/validator/src/rules/.

Tests

37 tests using Node's built-in node:test (zero new dependencies):

File Coverage
maxFileSize.test.js under/over limit, custom limit, null slots
i18nKeyConsistency.test.js consistent locales, missing key, extra key, <2 files
htmlSafety.test.js clean HTML, <script>, eval(), inline on* handlers
noExternalRefs.test.js relative paths, root-relative, data: URIs, external src/href/url()/\@import
validate.test.js full validate() integration, CLI exit codes 0/1/2, --json output

Run with: npm test

Spec

specs/payment-template-validator.md — Status: Done

🤖 Generated with Claude Code

carolkrroo and others added 8 commits May 31, 2026 15:10
Adds a `npm run validate -- <path>` CLI that runs the same
validation rules as the payment-templates-handler service, so
partners can catch errors locally before opening a ticket.

The maxFileSize rule is implemented as a reference — it is a
mirrored copy of the one in payment-templates-handler. The two
copies must stay in sync until they are extracted into a shared
module post-dojo.

Includes:
- validator/cli.js with human-readable + --json output
- validator/rules/index.js registry
- validator/rules/maxFileSize.js
- `validate` npm script
SDD spec following the team template. README covers how to run,
how to force an error case for testing, and the shared-contract
expectations with Squad A.
Extrai a lógica de validação pra um módulo standalone em packages/validator/,
consumido pelo CLI existente e pronto pra ser usado pelo Squad A no handler.

Implementa 4 rules: maxFileSize, i18nKeyConsistency, htmlSafety, noExternalRefs.
CLI agora é cliente fino da lib; 37 testes cobrindo todas as acceptance criteria.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ill add-validator-rule

- CLI mostra cada rule com status e contexto (describe) na saída padrão
- Cada rule expõe describe(template) com detalhes do que foi verificado
- runner retorna results por rule (details) além do array flat de errors
- examples/bad-templates/ com 5 cenários de erro para teste manual
- validator/README.md reescrito refletindo estrutura atual
- .agents/add-validator-rule.md: skill cross-tool para criar novas rules
- .claude/skills -> ../.agents via symlink (compatibilidade Claude + Cursor)
requiredFiles, noInlineStyles, noRelativeBacktrack, iconDimensions,
maxImageDimensions, cssScope, assetsReferenced — 80 tests, 0 failures.

Runner updated to distinguish error vs warning severity.
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