toolcraft-schema 0.0.224 → 0.0.226

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 +8 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,10 +19,10 @@ import { S, toJsonSchema, toJsonSchemaDocument, validateValue } from "toolcraft-
19
19
  import type { Static } from "toolcraft-schema";
20
20
 
21
21
  const schema = S.Object({
22
- name: S.String({ description: "User name" }),
23
- retries: S.Optional(S.Number({ default: 3 })),
22
+ name: S.String({ description: "User name", minLength: 1 }),
23
+ retries: S.Optional(S.Number({ default: 3, minimum: 0, jsonType: "integer" })),
24
24
  mode: S.Enum(["fast", "safe"] as const, { default: "safe" }),
25
- tags: S.Array(S.String(), { default: [] })
25
+ tags: S.Array(S.String(), { default: [], maxItems: 5 })
26
26
  });
27
27
 
28
28
  type Input = Static<typeof schema>;
@@ -64,15 +64,18 @@ const validation = validateValue(schema, {
64
64
 
65
65
  - `Static<typeof schema>` infers the runtime TypeScript shape for a schema descriptor.
66
66
  - Object properties wrapped in `S.Optional(...)` become optional properties in `Static`.
67
+ - Schemas declared with `nullable: true` infer `null` in `Static` and emit `nullable: true` in JSON Schema.
67
68
 
68
69
  ### JSON Schema generation
69
70
 
70
71
  - `toJsonSchema(schema)` converts any schema descriptor to standard JSON Schema.
71
72
  - `toJsonSchemaDocument(schema, options)` wraps `toJsonSchema(schema)` in a full JSON Schema document with `$schema`, optional `$id`, `title`, and `description`.
72
73
  - Object properties not wrapped in `S.Optional(...)` are emitted in `required`.
73
- - Defaults provided to schema builders are emitted as JSON Schema `default`.
74
- - Nested `S.Object(...)` schemas produce nested JSON Schema objects.
74
+ - Defaults provided to schema builders are emitted as JSON Schema `default` and must satisfy the schema.
75
+ - String, number, and array constraints are emitted as JSON Schema validation keywords.
76
+ - Nested `S.Object(...)` schemas produce nested JSON Schema objects. Object schemas default to `additionalProperties: false`; pass `additionalProperties: true` to allow unknown keys.
75
77
  - `S.Enum(...)` rejects empty or duplicate values at runtime for JavaScript callers.
78
+ - Invalid builder configuration fails fast, including invalid regex patterns, negative lengths/counts, inverted min/max pairs, non-finite numeric bounds, and integer schemas with non-integer defaults.
76
79
 
77
80
  ### Runtime validation
78
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.224",
3
+ "version": "0.0.226",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",