Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 1x 1x 11x 11x 1x 1x 11x 11x 1x | import { Injectable } from '@nestjs/common';
import { validate as isUuid } from 'uuid';
import { BaseValidationPipe, type BaseOptions } from './base-validation.pipe';
interface KeywordOptions extends BaseOptions {
keywords: string[];
}
@Injectable()
export class UuidOrKeywordPipe extends BaseValidationPipe<unknown> {
private readonly keywords: string[];
public constructor(options: KeywordOptions) {
super(options);
this.keywords = options.keywords;
}
public override validateOne(value: unknown): value is string {
return typeof value === 'string' && (this.keywords.includes(value) || isUuid(value));
}
public override transformOne(value: unknown): unknown {
return value;
}
}
|