UNPKG

@cowwoc/requirements

Version:

A fluent API for enforcing design contracts with automatic message generation.

27 lines 1.44 kB
import { AbstractCollectionValidator, Pluralizer, ObjectSizeValidatorImpl, ValidationTarget } from "../internal.mjs"; /** * Default implementation of `SetValidator`. */ class SetValidatorImpl extends AbstractCollectionValidator { /** * @param scope - the application configuration * @param configuration - the validator configuration * @param name - the name of the value * @param value - the value being validated * @param pluralizer - the type of items in the array * @param context - the contextual information set by a parent validator or the user * @param failures - the list of validation failures * @throws TypeError if `name` is `undefined` or `null` * @throws RangeError if `name` contains whitespace or is empty * @throws AssertionError if `scope`, `configuration`, `value` `context` or `failures` are null */ constructor(scope, configuration, name, value, pluralizer, context, failures) { super(scope, configuration, name, value, pluralizer, context, failures); } size() { this.failOnUndefinedOrNull(); return new ObjectSizeValidatorImpl(this.scope, this._configuration, this, this.name + ".size()", this.value.undefinedOrNullToInvalid().map(v => this.getLength(v)), this.pluralizer, this.context, this.failures); } } export { SetValidatorImpl }; //# sourceMappingURL=SetValidatorImpl.mjs.map