@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
33 lines (30 loc) • 1.64 kB
JavaScript
import { DEFAULT_STRING_FORMAT_PROPERTY_API_INTERFACE_CONSTANT } from '../../../constant/interface/api/property/default-string-format.constant.js';
import { ApplyGetDefaultStringFormatPropertiesCustomizer } from './customizer-apply.utility.js';
import cloneDeep from 'lodash/cloneDeep.js';
/**
* 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)
* @param {TApiGetDefaultStringFormatPropertiesParameters<TFormat>} parameters - Optional format-specific settings.
* @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,}$/"
* // }
* ```
* @template TFormat - Default string format type.
*/
function GetDefaultStringFormatProperties(format, ...parameters) {
const properties = cloneDeep(DEFAULT_STRING_FORMAT_PROPERTY_API_INTERFACE_CONSTANT.DEFAULT_FORMAT_PROPERTIES[format]);
return ApplyGetDefaultStringFormatPropertiesCustomizer(format, properties, ...parameters);
}
export { GetDefaultStringFormatProperties };
//# sourceMappingURL=utility.js.map