tiny-types
Version:
A tiny library that brings Tiny Types to JavaScript and TypeScript
15 lines (12 loc) • 377 B
text/typescript
import { MatcherRule } from './MatcherRule';
/**
* @access private
*/
export class MatchesRegExp<Output_Type> extends MatcherRule<string, Output_Type> {
constructor(private readonly pattern: RegExp, transformation: (v: string) => Output_Type) {
super(transformation);
}
matches(value: string): boolean {
return this.pattern.test(value);
}
}