@maioradv/nestjs-core 1.2.7 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
- export declare const IsStringClause: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
1
+ export declare const IsStringClause: (options?: {
2
+ isArray?: boolean;
3
+ }) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
2
4
  export declare const IsEnumClause: (model: object) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
3
5
  export declare const IsNumberClause: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
4
6
  export declare const IsBooleanClause: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -5,11 +5,20 @@ const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const class_transformer_1 = require("class-transformer");
7
7
  const class_validator_1 = require("class-validator");
8
- const IsStringClause = () => {
9
- return (0, common_1.applyDecorators)((0, swagger_1.ApiPropertyOptional)({
10
- type: String,
11
- description: 'Check if field contains the string'
12
- }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)());
8
+ const IsStringClause = (options) => {
9
+ const decorators = [
10
+ (0, swagger_1.ApiPropertyOptional)({
11
+ type: String,
12
+ description: options?.isArray ? 'A string or a comma-separated list of strings' : 'Check if field contains the string'
13
+ }),
14
+ (0, class_validator_1.IsOptional)(),
15
+ (0, class_validator_1.IsString)(),
16
+ ];
17
+ if (options?.isArray) {
18
+ decorators.push((0, class_validator_1.IsArray)());
19
+ decorators.push((0, class_transformer_1.Transform)(({ value }) => value.split(',')));
20
+ }
21
+ return (0, common_1.applyDecorators)(...decorators);
13
22
  };
14
23
  exports.IsStringClause = IsStringClause;
15
24
  const IsEnumClause = (model) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maioradv/nestjs-core",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "NestJS helpers by MaiorADV",
5
5
  "repository": "https://github.com/maioradv/nestjs-core.git",
6
6
  "author": "Maior ADV Srl",