Archived
2
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
definma-api/src/routes/validate/id.ts

17 lines
353 B
TypeScript
Raw Normal View History

2020-04-29 12:10:27 +02:00
import joi from '@hapi/joi';
export default class IdValidate {
private static id = joi.string().pattern(new RegExp('[0-9a-f]{24}')).length(24);
static get () {
return this.id;
}
static valid (id) {
return this.id.validate(id).error === undefined;
}
static parameter() { // :id url parameter
return ':id([0-9a-f]{24})';
}
}