UNPKG

self-assert

Version:

A small TypeScript library for designing models with built-in validity.

47 lines 1.74 kB
import type { Rule } from "./Rule"; import type { CollectableRule, MaybeAsync } from "./types"; import type { LabeledRule, LabelId } from "./types"; /** * Represents the evaluation of a rule on a given value. * * It can also be created using the {@link Rule.evaluateFor} method. * * @template ValueType The type of value the rule applies to. * * @example * {@includeCode ../../../../examples/snippets/rules.ts#evaluateFor,rule-evaluation} * * @category Rules */ export declare class RuleEvaluation<PredicateReturnType extends MaybeAsync<boolean>, ValueType> implements CollectableRule<void, PredicateReturnType extends boolean ? void : Promise<void>> { protected rule: Rule<PredicateReturnType, ValueType>; protected value: ValueType; constructor(rule: Rule<PredicateReturnType, ValueType>, value: ValueType); /** * @category Rule evaluation * @see {@link Rule.doesHold} */ doesHold(): PredicateReturnType; /** * @category Rule evaluation * @see {@link Rule.hasFailed} */ hasFailed(): PredicateReturnType; /** * @category Rule evaluation * @see {@link Rule.mustHold} */ mustHold(): PredicateReturnType extends boolean ? void : Promise<void>; /** * @category Rule evaluation * @see {@link Rule.collectFailureInto} */ collectFailureInto(failed: LabeledRule[]): PredicateReturnType extends boolean ? void : Promise<void>; isLabeledAs(aBrokenRuleLabel: LabeledRule): boolean; hasLabel(anId: LabelId, aDescription: string): boolean; hasDescription(aDescription: string): boolean; hasLabelId(anId: LabelId): boolean; getId(): LabelId; getDescription(): string; } //# sourceMappingURL=RuleEvaluation.d.ts.map