Migrate cafy to 14.0 (#4240)

This commit is contained in:
syuilo
2019-02-13 16:33:07 +09:00
committed by GitHub
parent b083430011
commit 5aa58da918
77 changed files with 334 additions and 345 deletions

View File

@ -25,9 +25,9 @@ export type ObjectId = mongo.ObjectID;
/**
* ID
*/
export default class ID extends Context<string> {
constructor() {
super();
export default class ID<Maybe = string> extends Context<string | Maybe> {
constructor(optional = false, nullable = false) {
super(optional, nullable);
this.push((v: any) => {
if (!isObjectId(v) && isNotAnId(v)) {
@ -40,4 +40,16 @@ export default class ID extends Context<string> {
public getType() {
return super.getType('string');
}
public makeOptional(): ID<undefined> {
return new ID(true, false);
}
public makeNullable(): ID<null> {
return new ID(false, true);
}
public makeOptionalNullable(): ID<undefined | null> {
return new ID(true, true);
}
}