@cobol-ts/validate 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +12 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,13 +1,19 @@
1
1
  # @cobol-ts/validate
2
2
 
3
- ## Purpose
3
+ Compose runtime validators for primitives, arrays, object shapes and dependent checks.
4
4
 
5
- Composable runtime validation for values and object shapes. Unlike TypeScript's compile-time types, these validators check supplied data and return results that callers can compose with other validation steps. The implementation uses the [errors](../errors/README.md) package's result model.
5
+ Validation returns structured errors rather than coercing untrusted data into TypeScript types.
6
6
 
7
- ## API
7
+ ## Composition
8
8
 
9
- `Validator<T, Source>` and `ValidationOptions<Source>` define the validation contract. The package includes `mustBeString`, `mustBeNumber`, `mustBeBoolean`, optional variants, `mustBeValue`, `mustBeArrayOf`, `mustBeObjectWithFields` and `mustBeNameAnd`. Higher-order composition includes `combineValidators`, `composeOr` and `composeTypedOr`. The map/flatMap helpers in `src/validator.map.flatmap.ts` provide eager and lazy forms for dependent validation sequences.
9
+ Use `mustBeString`, `mustBeNumber`, `mustBeArrayOf` and `mustBeObjectWithFields` for untrusted configuration. `combineValidators` combines independent checks; `validateMap` and `validateFlatMap` (and lazy counterparts) compose validation results without pretending that TypeScript annotations validate runtime input.
10
10
 
11
- ## Design guidance
11
+ Validation returns `ErrorsOr`; consumers decide whether to collect diagnostics or use `valueOrThrow` at their boundary.
12
12
 
13
- Use explicit validators for untrusted configurations and format metadata before handing them to the parser or layout compiler. Combinators that collect multiple errors should be distinguished from operations that stop on the first dependent failure. The exported functions are defined in [`src/validator.ts`](src/validator.ts) and [`src/validator.map.flatmap.ts`](src/validator.map.flatmap.ts), with tests describing concrete return values and error messages.
13
+ ## Source and tests
14
+
15
+ **Public entry points:** [validator.ts](./src/validator.ts), [validator.map.flatmap.ts](./src/validator.map.flatmap.ts).
16
+
17
+ **Tests:** [validator.map.flatmap.spec.ts](src/validator.map.flatmap.spec.ts), [validator.spec.ts](src/validator.spec.ts)
18
+
19
+ **Related:** [@cobol-ts/errors](../errors/README.md) · [@cobol-ts/file-catalogue](../../config/file-catalogue/README.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/validate",
3
3
  "description": "Validation for the @cobol-ts project",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {