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.
25 lines (22 loc) • 931 B
TypeScript
import { RequiredValidation } from '../../core.js';
import '../../commonTypes.js';
import '../../InferType.js';
import '../../helpers/constants.js';
/**
* @description Asserts that a string value ends with a specified substring.
* @param {string} substring The substring that the string value must end with.
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
* @throws {ValidationError} if the received value does not end with the required substring.
* @example
* const schema = string().custom(endsWith('bar'));
* parseOrFail(schema, 'foobar'); // Valid
* parseOrFail(schema, 'foofoo'); // Throws an error: 'The received value does not end with the required substring'
*
* @translation Error Translation Key = 's:endsWith'
*/
declare const endsWith: {
(substring: string): RequiredValidation;
key: string;
message: string;
};
export { endsWith };