import { HttpStep } from '../../HttpStep.js';
export const LessThanAssertionKind = 'HttpAction#LessThanAssertion';
/**
 * An assertion that makes sure the input value is less [or equal] to the set value.
 */
export class LessThanAssertion extends HttpStep {
    kind = LessThanAssertionKind;
    /**
     * The value to compare to.
     */
    value;
    /**
     * When set it treats the assertion as "greater than or equal"
     */
    equal;
    constructor(valueOrInit, equal) {
        super();
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'number') {
            this.new({
                kind: LessThanAssertionKind,
                value: valueOrInit,
                equal,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = LessThanAssertionKind;
        this.value = init.value;
        if (typeof init.equal === 'boolean') {
            this.equal = init.equal;
        }
        else {
            this.equal = undefined;
        }
    }
    checkValidity() {
        return typeof this.value === 'number';
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: LessThanAssertionKind,
        };
        if (this.value) {
            result.value = this.value;
        }
        if (typeof this.equal === 'boolean') {
            result.equal = this.equal;
        }
        return result;
    }
}
//# sourceMappingURL=LessThanAssertion.js.map