Documentation / @sw-file-lib/xml / xml-schema / Schema
Interface: Schema<T>
interface Schema {
readonly name: string;
safeParseValue: (input: SchemaInput, ctx: SchemaParseContext, options?: SchemaParseOptions) => Result<T, SchemaError>;
parseValue: (input: SchemaInput, ctx: SchemaParseContext, options?: SchemaParseOptions) => T;
safeParseField: (parent: SwXmlNode, key: string, ctx: SchemaParseContext, options?: SchemaParseOptions) => SchemaParseFieldResult<T>;
optional: () => OptionalSchema<Schema<T>>;
serializeField(value: unknown): SchemaSerializeResult;
}Defined in: packages/xml/src/xml-schema/types.ts:147
A schema that parses a Stormworks XML node into a typed value.
Extended by
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
|
| ‐ | |
| ( | Parses a Stormworks XML node or attribute value without throwing schema errors. This is a low-level operation used by schema implementations. For parsing a full XML tree, prefer ElementSchema.safeParse. | |
| ( | Parses a Stormworks XML node or attribute value. This is a low-level operation used by schema implementations. For parsing a full XML tree, prefer ElementSchema.parse. Throws SchemaError when the value does not match the schema. | |
| ( | Parses one field from an XML record node. Primitive schemas read attributes. Element schemas read child elements. This is primarily intended for schema implementations. Most callers should use ElementSchema.safeParse on a top-level element schema instead. | |
| () => | Returns a schema that accepts undefined values. |
Methods
serializeField()
serializeField(value: unknown): SchemaSerializeResult;Defined in: packages/xml/src/xml-schema/types.ts:194
Serializes one field without throwing.
This is primarily intended for schema implementations. Most callers should use ElementSchema.safeSerialize or ElementSchema.serialize on a top-level element schema instead.
Parameters
| Parameter | Type |
|---|---|
value | unknown |