Documentation / @sw-file-lib/xml / xml-schema / ElementSchema
Interface: ElementSchema<T>
interface ElementSchema extends Schema<T> {
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>>;
safeParse: (tree: string | SwXmlNodeList | Uint8Array<ArrayBufferLike>, rootTag: string, options?: SchemaParseOptions) => Result<T, SchemaError>;
parse: (tree: string | SwXmlNodeList | Uint8Array<ArrayBufferLike>, rootTag: string, options?: SchemaParseOptions) => T;
serializeField: (value: unknown) => ElementSchemaSerializeResult;
safeSerialize: (data: Immutable<T>, rootTag: string, writer?: XmlWriterOptions | XmlWriter) => Result<XmlWriter, SchemaSerializeError>;
serialize: (data: Immutable<T>, rootTag: string, writer?: XmlWriterOptions | XmlWriter) => XmlWriter;
}Defined in: packages/xml/src/xml-schema/types.ts:205
A schema that can parse and serialize a complete XML element.
Extends
Schema<T>
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Modifier | Type | Description | Overrides | Inherited from |
|---|---|---|---|---|---|
|
| ‐ | ‐ | ||
| ( | 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. | ‐ | ||
| ( | Parses a complete XML tree without throwing schema errors. The root element must have the supplied tag name. | ‐ | ‐ | |
| ( | Parses a complete XML tree. The root element must have the supplied tag name. Throws SchemaError when the value does not match the schema. | ‐ | ‐ | |
| ( | Serializes an element value without throwing. This is primarily intended for schema implementations. Most callers should use safeSerialize or serialize instead. | ‐ | ||
| ( | Serializes data into an XmlWriter without throwing an error. | ‐ | ‐ | |
| ( | Serializes data into an XmlWriter. Throws SchemaSerializeError when the value cannot be serialized by the schema. | ‐ | ‐ |