5.8 KiB
5.8 KiB
Archived 2026-04-19: all tasks retroactively ticked; package shipped under universal/validation/validation.
Tasks: enterprise-validation
1. Scaffold
- 1.1 Create
packages/universal/validation/withpackage.json,tsconfig.json,tsconfig.lib.json,vite.config.ts,vitest.config.ts,README.mdskeleton - 1.2 Register coverage thresholds at 100/100/100/100 in
vitest.config.ts; provider = istanbul - 1.3 Add cross-cutting guard tests in
tests/: dep-graph, no-disallowed, tree-shake - 1.4 Add package to root
CLAUDE.md,README.md, andSTRUCTURE.yml
2. Core types + errors
- 2.1 Implement
src/types/common.ts—AnySchema,SchemaInput,SchemaOutput,Infer,InferInput,ParseResult,ParseSuccess,ParseFailure,ParseContext,ValidationIssue,ValidationCode,FlattenedErrors,RefineFn,AsyncRefineFn,TransformFn,CustomRule,StringRuleOptions,NumberRuleOptions,ObjectShape - 2.2 Implement
src/types/validation-hooks.ts—ValidationHookMap,ValidationHookData,ValidationValidatingHandler - 2.3 Implement
src/errors/errors.ts—ValidationErrorextendsSuaveplanError; stable codes underVALIDATION.*;.flatten(),.issues,.format()methods - 2.4 Implement
src/errors/errors.types.ts—ValidationErrorOptions,FlattenedErrors - 2.5 Tests for
ValidationError: construction,.flatten(),.format(), nested issues
3. BaseSchema
- 3.1 Implement
src/core/schema/schema.ts— abstractBaseSchema<TInput, TOutput>with.parse(),.safeParse(),.parseAsync(),.safeParseAsync(),.refine(),.transform(),.optional(),.nullable(),.describe() - 3.2 Implement
src/core/schema/schema.types.ts— re-exportAnySchema,SchemaInput,SchemaOutput - 3.3 Tests: sync/async parse, refine pass/fail, transform, chaining
.optional().nullable() - 3.4 Property-based tests: any valid
Talways returnsParseSuccess; any invalid always returnsParseFailure(never throws) - 3.5 Co-located
src/core/schema/schema.md
4. Primitive schemas
- 4.1
src/schemas/string/string.ts—StringSchema,string()factory with.min(),.max(),.length(),.regex(),.email(),.url(),.uuid(),.startsWith(),.endsWith(),.includes(),.trim(),.toLowerCase(),.toUpperCase() - 4.2
src/schemas/number/number.ts—NumberSchema,number()with.min(),.max(),.int(),.positive(),.negative(),.multipleOf(),.finite() - 4.3
src/schemas/boolean/boolean.ts—BooleanSchema,boolean() - 4.4
src/schemas/date/date.ts—DateSchema,date()with.min(),.max() - 4.5 Unit tests for every constraint method; co-located
.mdfor each
5. Composite schemas
- 5.1
src/schemas/array/array.ts—ArraySchema,array(schema)with.min(),.max(),.length(),.nonempty() - 5.2
src/schemas/object/object.ts—ObjectSchema,object(shape)with.strict(),.passthrough(),.strip(),.pick(),.omit(),.partial(),.required(),.extend(),.merge() - 5.3
src/schemas/record/record.ts—RecordSchema,record(schema) - 5.4
src/schemas/tuple/tuple.ts—TupleSchema,tuple(schemas) - 5.5 Unit tests for each; co-located
.mdfor each
6. Modifier + combinator schemas
- 6.1
src/schemas/optional/optional.ts—OptionalSchema,optional(schema) - 6.2
src/schemas/nullable/nullable.ts—NullableSchema,nullable(schema) - 6.3
src/schemas/literal/literal.ts—LiteralSchema,literal(value) - 6.4
src/schemas/enum/enum.ts—EnumSchema,enumeration(values) - 6.5
src/schemas/union/union.ts—UnionSchema,union(schemas)— short-circuit on first match - 6.6
src/schemas/intersection/intersection.ts—IntersectionSchema,intersection(a, b) - 6.7 Unit tests; property-based tests for union (no match → failure, first match wins)
- 6.8 Co-located
.mdfor each
7. Coerce utilities
- 7.1
src/utils/coerce.ts—coerce(schema),coerceString,coerceNumber,coerceBoolean,coerceDate,CoercedSchema - 7.2 Unit tests: string→number, "true"→boolean, timestamp→date, invalid coerce → failure
- 7.3 Co-located
src/utils/coerce.md
8. Compose utilities
- 8.1
src/utils/compose.ts—mergeResults(results),pipe(schema, ...transforms) - 8.2 Tests: merge empty / all-success / mixed; pipe chain preserves type
- 8.3 Co-located
src/utils/compose.md
9. OTel instrumentation
- 9.1 Counter
validation.parse.successandvalidation.parse.failure(by schema-type label) - 9.2 Histogram
validation.parse.duration_ms - 9.3 No-op without exporter (tested)
10. Benchmarks
- 10.1
src/__benchmarks__/object.bench.ts—object(shape).parse(data)10-field object, 100k iterations - 10.2
src/__benchmarks__/array.bench.ts—array(string()).parse(arr)1 000-element array - 10.3
src/__benchmarks__/union.bench.ts— union 10 arms, best-case and worst-case branch - 10.4 Publish baseline numbers in README
11. Docs
- 11.1 Co-located
.mdfor every implementation file (≥200 words, examples, API reference) - 11.2 Rewrite
README.mdwith full public API, design rationale, comparison with Zod, consumer guide - 11.3
bun run docs:check --filter=@suaveplan/validation≥ 90%
12. Verify and publish
- 12.1
bunx turbo lint typecheck test --filter=@suaveplan/validationgreen - 12.2
bunx turbo test:coverage --filter=@suaveplan/validationat 100/100/100/100 - 12.3
bunx turbo build --filter=@suaveplan/validationgreen - 12.4
bun scripts/publish.ts --package @suaveplan/validationto Verdaccio at 0.0.0 - 12.5 Archive OpenSpec change to
openspec/archive/2026-04-18-enterprise-validation/