import { HttpStep } from '../../HttpStep.js';
export const LengthOfAssertionKind = 'HttpAction#LengthOfAssertion';
/**
 * An assertion that makes sure the input has a length of the specified value.
 */
export class LengthOfAssertion extends HttpStep {
    kind = LengthOfAssertionKind;
    /**
     * The expected size of the array.
     */
    value;
    constructor(valueOrInit) {
        super();
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'number') {
            this.new({
                kind: LengthOfAssertionKind,
                value: valueOrInit,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = LengthOfAssertionKind;
        this.value = init.value;
    }
    checkValidity() {
        return typeof this.value === 'number';
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: LengthOfAssertionKind,
        };
        if (typeof this.value === 'number') {
            result.value = this.value;
        }
        return result;
    }
}
//# sourceMappingURL=LengthOfAssertion.js.map