import { Assert } from '@rsdk/common'; import assert from 'node:assert'; import type { PropertyParser } from '../../types'; export class StringParser implements PropertyParser { constructor(private readonly pattern?: RegExp) {} type(): string { return 'string'; } description(): string { return 'Extract arbitrary string.'; } parse(value: unknown): string { Assert.isString(value); if (this.pattern) { assert(this.pattern.test(value)); } return value; } }