import { KeyOf } from "@mantlebee/ts-core"; import { generateRandomStringFromPattern } from "@mantlebee/ts-random"; import { ColumnAbstract } from "@/models"; /** * Generates a random string, satisfying a defined pattern. * The random string is generated by the {@link generateRandomStringFromPattern} method from the `@mantlebee/ts-random` package. */ export class PatternColumn extends ColumnAbstract { public readonly pattern!: string; /** * @param name Name of the column and of the field. * @param pattern Pattern that the random string must be satisfies. */ public constructor(name: KeyOf, pattern: string) { super(name); this.pattern = pattern; } public getValue(): string { return generateRandomStringFromPattern(this.pattern); } }