Data.ValidationError
luastra/dataData.ValidationError represents the unsuccessful branch of a bounded operation. Its stable code and structured context support control flow and safe diagnostics without parsing an exception message.
Before you use it
Add luastra/data to this module's dependencies in luastra.json, then import it with require("luastra/data"). No host capability is required. Define schemas outside render when they are reused.
How it fits
The exported type describes schemas or the tagged success/failure result returned by Data.decode.
When to use it
Use Data.ValidationError on the unsuccessful branch of the related result. Read its stable fields for control flow or diagnostics; do not parse human-readable assertion or error text.
Fields or definition
| Parameter | Type / values | Description |
|---|---|---|
| code | string | Stable machine-readable failure code suitable for branching and diagnostics. |
| path | string | Checked path field of Data.ValidationError; its exact admitted type is string. |
Error codes
This is the complete closed vocabulary emitted by the named operation in this Source SDK contract.
| Code | When it occurs |
|---|---|
| invalid_schema | The supplied schema is not a valid Data.Schema value. |
| maximum_depth | Nested validation exceeded the supported schema depth. |
| schema_cycle | The schema recursively references itself. |
| expected_string | The value at path is not a string. |
| too_short | A string contains fewer bytes than minBytes. |
| too_long | A string contains more bytes than maxBytes. |
| expected_number | The value is not a finite number. |
| expected_integer | The value is not an integer required by the schema. |
| too_small | A number is below the configured minimum. |
| too_large | A number is above the configured maximum. |
| expected_boolean | The value at path is not a boolean. |
| expected_array | The value is not a dense one-based array. |
| too_few_items | An array contains fewer items than minItems. |
| too_many_items | An array contains more items than maxItems. |
| expected_object | The value at path is not an object table. |
| unexpected_field | An exact object contains a field absent from its schema. |
| unknown_schema | The schema kind is not supported by this SDK version. |
SDK type flow
Produced by
What happens next
A checked schema/result annotation.
Failures and fixes
Ordinary invalid input is a Data.decode failure, not an exception. Invalid schema options are programmer errors and fail immediately. String bounds count UTF-8 bytes; Data.string has no pattern option in this alpha.
Availability
Public-source alpha API in 0.5.0-alpha; host-independent and synchronous.
Exact declaration
export type ValidationError = {
code: string,
path: string,
}