EntitySchemaclass

new EntitySchema<T>({ one = "entity", title = "Entity", types, ...options }: EntitySchemaOptions<T>)
ParamType
optionsEntitySchemaOptions<T>
Options for EntitySchema. required
    .typesImmutableArray<T>
Restrict the allowed entity types; any other type is rejected. readonly
Return
EntitySchema<T>
Schema that validates an Entity string combining a type and ID, e.g.
PropertyType
.typesImmutableArray<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 types is 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"