@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
30 lines (27 loc) • 1.32 kB
JavaScript
import { DEFAULT_STRING_FORMAT_PROPERTY_API_INTERFACE_CONSTANT } from '../../../constant/interface/api/property/default-string-format.constant.js';
import cloneDeep from 'lodash/cloneDeep';
/**
* Returns default format properties for supported string types (EMAIL, IP, URL, UUID).
* This utility provides standard validation rules including pattern, length constraints,
* example values and descriptions for common string formats.
* @param {TApiPropertyDefaultStringFormat} format - The string format type (EMAIL, IP, URL, or UUID)
* @returns {TApiPropertyDefaultStringFormatProperties} Default properties for the specified format
* @example
* ```typescript
* const emailDefaults = GetDefaultStringFormatProperties(TApiPropertyDefaultStringFormat.EMAIL);
* // Returns:
* // {
* // description: "email",
* // exampleValue: "user@example.com",
* // maxLength: 321,
* // minLength: 5,
* // pattern: "/^([a-zA-Z0-9_\\-.+])+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}$/"
* // }
* ```
*/
function GetDefaultStringFormatProperties(format) {
const properties = DEFAULT_STRING_FORMAT_PROPERTY_API_INTERFACE_CONSTANT.DEFAULT_FORMAT_PROPERTIES[format];
return cloneDeep(properties);
}
export { GetDefaultStringFormatProperties };
//# sourceMappingURL=get-default-string-format-properties.utility.js.map