← Runtime data validation

Data.Success

luastra/data

Data.Success represents the successful branch of a discriminated SDK result. Its value and success-specific fields are safe to read only after the shared success tag has narrowed the union.

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.Success after narrowing the related result with success == true. Only this branch guarantees access to the decoded value and other success-specific fields.

Fields or definition

ParameterType / valuesDescription
successtrueDiscriminator that must be checked before reading branch-specific fields.
valueanyValidated value available on the successful result branch.
errornilBounded failure information, or nil on the successful branch.

SDK type flow

Produced by

Data.decode

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 Success = { success: true, value: any, error: nil }

Complete inventory

View all pages in Runtime data validation
← Previous: Data.ValidationErrorNext: Data.Failure →