SchemaStatics Interface
Stateless APIs exposed via SchemaFactory as both instance properties and as statics.
For more information about our API support guarantees, see here.
Signature
/** @sealed */
export interface SchemaStatics
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
boolean | readonly |
LeafSchema<"boolean", boolean> | TreeNodeSchema for holding a boolean. |
handle | readonly |
LeafSchema<"handle", IFluidHandle> | TreeNodeSchema for holding an IFluidHandle. |
leaves | readonly |
readonly [ SchemaStatics["string"], SchemaStatics["number"], SchemaStatics["boolean"], SchemaStatics["null"], SchemaStatics["handle"] ] | AllowedTypes for holding any of the leaf types. |
null | readonly |
LeafSchema<"null", null> | TreeNodeSchema for JavaScript null . |
number | readonly |
LeafSchema<"number", number> | TreeNodeSchema for holding a JavaScript number . |
optional | readonly |
<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Optional, T, TCustomMetadata> | Make a field optional instead of the default, which is required. |
optionalRecursive | readonly |
<const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata> | optional except tweaked to work better for recursive types. Use with ValidateRecursiveSchema for improved type safety. |
required | readonly |
<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Required, T, TCustomMetadata> | Make a field explicitly required. |
requiredRecursive | readonly |
<const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata> | required except tweaked to work better for recursive types. Use with ValidateRecursiveSchema for improved type safety. |
string | readonly |
LeafSchema<"string", string> | TreeNodeSchema for holding a JavaScript string . |
Property Details
boolean
TreeNodeSchema for holding a boolean.
For more information about our API support guarantees, see here.
Signature
readonly boolean: LeafSchema<"boolean", boolean>;
Type: LeafSchema<"boolean", boolean>
handle
TreeNodeSchema for holding an IFluidHandle.
For more information about our API support guarantees, see here.
Signature
readonly handle: LeafSchema<"handle", IFluidHandle>;
Type: LeafSchema<"handle", IFluidHandle>
leaves
AllowedTypes for holding any of the leaf types.
For more information about our API support guarantees, see here.
Signature
readonly leaves: readonly [
SchemaStatics["string"],
SchemaStatics["number"],
SchemaStatics["boolean"],
SchemaStatics["null"],
SchemaStatics["handle"]
];
Type: readonly [ SchemaStatics["string"], SchemaStatics["number"], SchemaStatics["boolean"], SchemaStatics["null"], SchemaStatics["handle"] ]
null
TreeNodeSchema for JavaScript null
.
For more information about our API support guarantees, see here.
Signature
readonly null: LeafSchema<"null", null>;
Type: LeafSchema<"null", null>
Remarks
There are good reasons to avoid using null in JavaScript, however sometimes it is desired. This TreeNodeSchema node provides the option to include nulls in trees when desired. Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
number
TreeNodeSchema for holding a JavaScript number
.
For more information about our API support guarantees, see here.
Signature
readonly number: LeafSchema<"number", number>;
Type: LeafSchema<"number", number>
Remarks
The number is a double-precision 64-bit binary format IEEE 754 value, however there are some exceptions: - NaN
, and the infinities are converted to null
(and may therefore only be used where null
is allowed by the schema). - -0
may be converted to 0
in some cases.
These limitations match the limitations of JSON.
optional
Make a field optional instead of the default, which is required.
For more information about our API support guarantees, see here.
Signature
readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>;
Type: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Optional, T, TCustomMetadata>
optionalRecursive
optional except tweaked to work better for recursive types. Use with ValidateRecursiveSchema for improved type safety.
For more information about our API support guarantees, see here.
Signature
readonly optionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>;
Type: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Optional, T, TCustomMetadata>
Remarks
This version of optional has fewer type constraints to work around TypeScript limitations, see Unenforced. See ValidateRecursiveSchema for additional information about using recursive schema.
required
Make a field explicitly required.
For more information about our API support guarantees, see here.
Signature
readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Required, T, TCustomMetadata>;
Type: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => FieldSchema<FieldKind.Required, T, TCustomMetadata>
Remarks
Fields are required by default, but this API can be used to make the required nature explicit in the schema, and allows associating custom properties with the field.
requiredRecursive
required except tweaked to work better for recursive types. Use with ValidateRecursiveSchema for improved type safety.
For more information about our API support guarantees, see here.
Signature
readonly requiredRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>;
Type: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">) => System_Unsafe.FieldSchemaUnsafe<FieldKind.Required, T, TCustomMetadata>
Remarks
This version of required has fewer type constraints to work around TypeScript limitations, see Unenforced. See ValidateRecursiveSchema for additional information about using recursive schema.
string
TreeNodeSchema for holding a JavaScript string
.
For more information about our API support guarantees, see here.
Signature
readonly string: LeafSchema<"string", string>;
Type: LeafSchema<"string", string>
Remarks
Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode. JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.