self-assert
Version:
A small TypeScript library for designing models with built-in validity.
28 lines • 1.19 kB
TypeScript
import { RuleLabel } from "./RuleLabel";
import { Rule } from "./Rule";
import { LabeledRule, LabelId } from "./types";
/**
* Represents a rule that needs to be evaluated **asynchronously**.
*
* @example
* {@includeCode ../../../../examples/snippets/rules.ts#inquiry}
*
* @category Rules
*/
export declare class Inquiry<ValueType = any> extends Rule<Promise<boolean>, ValueType> {
/** @category Creation */
static labeled<ValueType = any>(anId: LabelId, aDescription: string): Inquiry<ValueType>;
/** @internal */
static requiring(anId: LabelId, aDescription: string, aCondition: () => Promise<boolean>): Inquiry<void>;
/**
* @see {@link Assertion.requiring}
* @category Creation
*/
static requiring<ValueType = any>(anId: LabelId, aDescription: string, aCondition: (value: ValueType) => Promise<boolean>): Inquiry<ValueType>;
protected constructor(label: RuleLabel);
doesHold(value: ValueType): Promise<boolean>;
hasFailed(value: ValueType): Promise<boolean>;
mustHold(value: ValueType): Promise<void>;
collectFailureInto(failed: LabeledRule[], value: ValueType): Promise<void>;
}
//# sourceMappingURL=Inquiry.d.ts.map