import Context from '../ctx' ; /**
 * Literal
 */ export default class LiteralContext < Literal , Maybe extends null | undefined | Literal = Literal > extends Context < Literal | Maybe > { public readonly name = 'Literal' ; public readonly literal : any ; constructor ( literal , optional = false , nullable = false ) { super ( optional , nullable ) ; this . literal = literal ; this . push ( v => v !== literal ? new Error ( 'must be ' + literal ) : true ) ; } public getType ( ) { return super . getType ( typeof this . literal === 'string' ? `'${ this . literal }'` : this . literal ) ; } public makeOptional ( ) { return new LiteralContext ( this . literal , true , false ) ; } public makeNullable ( ) { return new LiteralContext ( this . literal , false , true ) ; } public makeOptionalNullable ( ) { return new LiteralContext ( this . literal , true , true ) ; } }