Archive add-shared-schema-package and swap-superstruct-valibot changes to openspec/changes/archive/
1.5 KiB
1.5 KiB
ADDED Requirements
Requirement: Define Superstruct validators for data shapes
The package SHALL export Superstruct schema definitions for validating runtime data shapes (request payloads, configuration objects, etc.).
Scenario: Validator validates correct data
- WHEN data matching the schema is passed to the validator
- THEN the validator SHALL return the validated data without throwing
Scenario: Validator rejects invalid data
- WHEN data not matching the schema is passed to the validator
- THEN the validator SHALL throw a
StructErrorwith details about the validation failure
Requirement: Validator composability
Superstruct schemas SHALL be composable — schemas can reference other schemas for nested object validation.
Scenario: Nested object validation
- WHEN a schema defines a nested object field using another Superstruct schema
- THEN the nested schema SHALL be applied during validation of the parent
Requirement: Optional and default fields
Superstruct schemas SHALL support optional fields (optional()) and fields with default values (defaulted()) for partial updates or configuration defaults.
Scenario: Optional field omitted
- WHEN an optional field is omitted from input data
- THEN the validator SHALL accept the data and not require the field
Scenario: Default value applied
- WHEN a field with a default value is omitted from input data
- THEN the validator SHALL apply the default value in the returned data