31 lines
1.2 KiB
Markdown
31 lines
1.2 KiB
Markdown
## ADDED Requirements
|
|
|
|
### Requirement: Schema package provides schema registry
|
|
The `@suaveplan/bitpacker-schema` package SHALL expose a `SchemaRegistry` that stores named schemas and resolves `_ref` tokens.
|
|
|
|
#### Scenario: Register and retrieve named schema
|
|
- **WHEN** `registry.register("player", { name: "-16", health: 255 })` is called
|
|
- **THEN** `registry.resolve("player")` returns the registered schema
|
|
|
|
### Requirement: Schema package provides validation
|
|
The `@suaveplan/bitpacker-schema` package SHALL validate that data conforms to a schema before packing.
|
|
|
|
#### Scenario: Validate data against schema
|
|
- **WHEN** `validate(data, schema)` is called with data that exceeds a numeric range
|
|
- **THEN** a `BitpackerError` is thrown with code `VALUE_OUT_OF_RANGE`
|
|
|
|
### Requirement: Schema package supports versioning
|
|
The `@suaveplan/bitpacker-schema` package SHALL support schema versioning with forward-compatibility rules.
|
|
|
|
#### Scenario: Versioned schema migration
|
|
- **WHEN** a schema contains `{ _version: 2, _schemas: [oldSchema, newSchema] }`
|
|
- **THEN** the correct schema is selected based on the version number
|
|
|
|
## MODIFIED Requirements
|
|
|
|
None.
|
|
|
|
## REMOVED Requirements
|
|
|
|
None.
|