bguard
Version:
**bguard** is a powerful, flexible, and type-safe validation library for TypeScript. It allows developers to define validation schemas for their data structures and ensures that data conforms to the expected types and constraints.
26 lines (23 loc) • 1.07 kB
TypeScript
import { RequiredValidation } from '../../core.js';
import '../../commonTypes.js';
import '../../InferType.js';
import '../../helpers/constants.js';
/**
* @description Asserts that the length of na array is not less than a specified minimum length.
* @param {number} expected The minimum required length for the array.
* @returns {RequiredValidation} A validation function that takes a received array and an exception context.
* @throws {ValidationError} if the length of the received value is less than the expected length.
* @example
* const schema = array(string()).custom(minArrayLength(3));
* parseOrFail(schema, ['short', 'array']); // Throws an error: 'The received value length is less than expected'
* parseOrFail(schema, ['adequate', 'array', 'length']); // Valid
* parseOrFail(schema, ['adequate', 'array', 'length', 'test']); // Valid
*
* @translation Error Translation Key = 'a:minArrayLength'
*/
declare const minArrayLength: {
(expected: number): RequiredValidation;
key: string;
message: string;
};
export { minArrayLength };