Migrating to schema-dsl v3
schema-dsl v3 makes one deliberate breaking change: importing or requiring the package root no longer mutates String.prototype.
Root imports
The root and schema-dsl/pure expose the same side-effect-free core API. Existing code that already uses s(...), dsl(...), validate(...), builders, exporters, or schema-dsl/runtime can keep its API calls.
Direct String chains
Code that calls methods directly on string literals must opt in at application startup:
Use schema-dsl/compat as a single import when preserving the v1/v2 runtime behavior is clearer. Libraries should normally prefer builders such as s('email!').description(...) and avoid changing host prototypes.
Required, optional, and null
!marks a property as required. Compile the complete object and read standard JSON Schemarequired[].?marks a property as optional. It does not allownull.- Allow
nullexplicitly with a null union such astypes:string|nullor raw JSON Schema{ type: ['string', 'null'] }. - v3 does not add
isRequired()orisOptional()getters;_requiredand_optionalare internal compatibility details.
Validation results
valid and normalized data remain stable. Canonical errors use path, message, and keyword; legacy field, type, and expected aliases remain for v3.0 compatibility but are deprecated. New integrations should map from canonical fields at their own public boundary.