import { Context } from 'cafy'; // eslint-disable-next-line @typescript-eslint/ban-types export class ID extends Context { public readonly name = 'ID'; constructor(optional = false, nullable = false) { super(optional, nullable); this.push((v: any) => { if (typeof v !== 'string') { return new Error('must-be-an-id'); } return true; }); } public getType() { return super.getType('String'); } public makeOptional(): ID { return new ID(true, false); } public makeNullable(): ID { return new ID(false, true); } public makeOptionalNullable(): ID { return new ID(true, true); } }