5.5 KiB
5.5 KiB
Validation Rules
Validation is now a lightweight automated gate instead of a prose-only checklist.
Commands
npm run generate:domain-summarynpm run validate:generationnpm run validate:generation:runtime
Prompt-Gate Alignment Rule
- Every invariant described as required in the active prompt corpus must either be enforced by this gate or be called out explicitly as a manual/runtime-only check.
- Validation must not stay silent about a violation that the prompts describe as forbidden.
- Validation must not report green buildability when build verification was skipped.
Gate groups
Build checks
- at least one
domain/*.dslfile exists - required artifacts exist
- Prisma schema exists
- frontend/backend env contracts exist
- frontend/backend framework workspace files exist
domain-summary.jsonmatches the current DSL- project
.env.examplefiles keep the working domain-based Keycloak examples unless explicitly overridden server/remains a valid Nest workspaceclient/remains a valid Vite workspace- generation must not pass validation if framework scaffolding files were deleted and replaced by a hand-written minimal skeleton
- if dependencies are installed, build verification runs for
server/andclient/ - if dependencies are missing, build verification is reported as skipped with reason instead of green
server/package.jsonandclient/package.json: every entry independencies,devDependencies,optionalDependencies, andpeerDependenciesmust use an exact version string (no^or~prefix)
Auth checks
- frontend auth seam files exist
- backend auth seam files exist
401and403semantics stay split- auth code keeps the required Keycloak/JWT contracts
- JWKS resolution chain matches the contract:
- explicit
KEYCLOAK_JWKS_URL - OIDC discovery
- certs fallback
- explicit
Filter checks
- list resources expose filter UI (including
FilterButton) - reference filters use
ReferenceInput+AutocompleteInputwithfilterToQuery - data provider preserves repeated query params for array filters
- backend FK filters keep exact-match semantics
- enum repeated params are mapped to Prisma
in - typed form mapping is preserved:
integer/decimal->NumberInputdate->DateInput
- reference fields intended for navigation keep
ReferenceField link="show" - resources keep
show={...}registration inApp.tsx
Natural-key checks
- response records expose
id - route/update contracts use the real primary key
- natural-key sort/update paths do not regress to a fake physical
id
Realm checks
- a root
*-realm.jsonartifact exists - realm roles exist
- audience delivery exists
- required claims are explicit
- SPA/backend client structure is explicit
Runtime checks
- compose topology stays PostgreSQL-only
- Prisma lifecycle scripts remain in place
/healthstays public- backend can execute
npm run buildinsideserver/ - frontend can execute
npm run buildinsideclient/after dependencies are installed - client/server
.env.examplestay aligned with the working runtime defaults:https://sso.greact.rutoirtoir-frontendtoir-backendhttps://toir-frontend.greact.ru
- optional runtime execution mode runs:
npx prisma generatenpx prisma migrate devnpx prisma db seed
API error contract (backend ↔ frontend)
- Backend errors use the shared
ApiExceptionFiltershape:statusCode,message(stringorstring[]— для списков ошибок валидации),code, optionaldetails,path,timestamp. - Список ошибок валидации отдаётся в JSON как
message: string[], без склейки через", "на сервере (клиент сам склеивает для UI, например через\n). - Клиентский
dataProviderне должен резать одну строкуmessageпо запятым — только обрабатывать массив или целую строку. - Подписи полей для русских сообщений
ValidationPipeгенерируются из DSL вserver/src/common/field-labels.generated.ts(не дублировать огромный словарь вручную вmain.ts). - Поля DSL
decimalв DTO принимают число (как шлёт React AdminNumberInput); в сервисе конвертация вPrisma.Decimalсохраняется. - Атрибуты-enum в DTO валидируются
@IsIn([...])по значениям enum из DSL, а не только@IsString. - Бандл AID (
collectGeneratedBundle) включает копииgeneration/templates/runtime/*(main.ts,api-exception.filter.ts,dataProvider.ts,AppNotification.tsx) — это канонический источник для шва ошибок; при--applyони перезаписываются вserver/иclient/.
Scaffold checks
- backend initialization starts from official Nest CLI scaffolding
- frontend initialization starts from official Vite React TypeScript scaffolding
- feature generation happens after scaffold creation, not instead of scaffold creation
- repair happens before generation when workspace is degraded
- required framework configs and entry files must survive subsequent LLM edits
The automated gate is intentionally small. It enforces the critical reproducibility contract without turning the repository into a test platform or a generator engine.