EntitySchemaclass
new EntitySchema<T>({ one = "entity", title = "Entity", types, ...options }: EntitySchemaOptions<T>)| Param | Type | |
|---|---|---|
options | EntitySchemaOptions<T> | Options for EntitySchema. required |
.types | ImmutableArray<T> | Restrict the allowed entity types; any other type is rejected. readonly |
| Return | |
|---|---|
EntitySchema<T> |
| Property | Type | |
|---|---|---|
.types | ImmutableArray<T> | Immutable array: an array that cannot be changed. readonly |
Schema that validates an Entity string combining a type and ID, e.g. challenge:a1b2c3.
- The input must contain both a type and an ID separated by
:, otherwise it is rejected. - When
typesis set, the entity's type must be one of the allowed types.
Examples
const schema = new EntitySchema({ types: ["challenge"] });
schema.validate("challenge:a1b2c3"); // "challenge:a1b2c3"