requireEntity()function

requireEntity(entity: Entity<T>, caller?: AnyCaller): [type: T, id: string]
requireEntity(entity: string, caller?: AnyCaller): [type: string, id: string]
ParamType
entityEntity<T>
The entity string to split. required
callerAnyCaller
Function to attribute a thrown error to (defaults to requireEntity).
entitystring
required
callerAnyCaller
Any calling function or constructor, usually referring to something that can call in the current scope that can appear in a stack trace.
Return
[type: T, id: string]
A [type, id] tuple.
[type: string, id: string]
Throws
RequiredError
If the entity string is missing or invalid.

Split an entity tag like challenge:a1b2c3 into its type and id, or throw RequiredError if the entity tag was invalid.

Examples

requireEntity("challenge:a1b2c3") // ["challenge", "a1b2c3"]