feat(validator): implement payment-template-validator lib (Squad B)#6
Open
huandrey wants to merge 8 commits into
Open
feat(validator): implement payment-template-validator lib (Squad B)#6huandrey wants to merge 8 commits into
huandrey wants to merge 8 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/validator/src/exposingasync validate(dir, opts) → {ok, errors}. The CLI atvalidator/cli.jsis now a thin client that calls the lib.--jsonflag produces machine-readable output for CI pipelines; exit codes 0 (valid), 1 (validation errors), 2 (usage errors) are enforced.maxFileSize,i18nKeyConsistency,htmlSafety,noExternalRefs— all pluggable viapackages/validator/src/rules/.Tests
37 tests using Node's built-in
node:test(zero new dependencies):maxFileSize.test.jsi18nKeyConsistency.test.jshtmlSafety.test.js<script>,eval(), inlineon*handlersnoExternalRefs.test.jsdata:URIs, externalsrc/href/url()/\@importvalidate.test.jsvalidate()integration, CLI exit codes 0/1/2,--jsonoutputRun with:
npm testSpec
specs/payment-template-validator.md— Status: Done🤖 Generated with Claude Code