Sindbad~EG File Manager
{"version":3,"file":"ArrayMaxSize.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayMaxSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW;IACtD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,iBAAqC;IAC7E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAzC,CAAyC;YAC7E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,2DAA2D,EAAxE,CAAwE,EACtF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\n\nexport const ARRAY_MAX_SIZE = 'arrayMaxSize';\n\n/**\n * Checks if the array's length is less or equal to the specified number.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayMaxSize(array: unknown, max: number): boolean {\n return Array.isArray(array) && array.length <= max;\n}\n\n/**\n * Checks if the array's length is less or equal to the specified number.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayMaxSize(max: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_MAX_SIZE,\n constraints: [max],\n validator: {\n validate: (value, args): boolean => arrayMaxSize(value, args?.constraints[0]),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must contain no more than $constraint1 elements',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists