import { HttpStep } from '../../HttpStep.js';
export const MatchesAssertionKind = 'HttpAction#MatchesAssertion';
/**
 * An assertion that makes sure the input value matches a regexp.
 */
export class MatchesAssertion extends HttpStep {
    kind = MatchesAssertionKind;
    /**
     * The regexp to match the value against.
     */
    value;
    constructor(valueOrInit) {
        super();
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'string') {
            this.new({
                kind: MatchesAssertionKind,
                value: valueOrInit,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = MatchesAssertionKind;
        this.value = init.value;
    }
    checkValidity() {
        return !!this.value;
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: MatchesAssertionKind,
        };
        if (this.value) {
            result.value = this.value;
        }
        return result;
    }
}
//# sourceMappingURL=MatchesAssertion.js.map