requireEntity()function
requireEntity(entity: Entity<T>, caller?: AnyCaller): [type: T, id: string]
requireEntity(entity: string, caller?: AnyCaller): [type: string, id: string]
| Param | Type | |
|---|---|---|
entity | Entity<T> | The entity string to split. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to requireEntity). |
entity | string | required |
caller | AnyCaller | 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"]