UNPKG

2.05 kBSource Map (JSON)View Raw
1{"version":3,"file":"ArrayNotContains.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayNotContains.ts"],"names":[],"mappings":";;;AACA,qDAAgE;AAEnD,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAAc,EAAE,MAAa;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAJD,4CAIC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAa,EAAE,iBAAqC;IACnF,OAAO,IAAA,uBAAU,EACf;QACE,IAAI,EAAE,0BAAkB;QACxB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAChF,cAAc,EAAE,IAAA,yBAAY,EAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,kDAAkD,EAC7E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAfD,4CAeC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\n\nexport const ARRAY_NOT_CONTAINS = 'arrayNotContains';\n\n/**\n * Checks if array does not contain any of the given values.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayNotContains(array: unknown, values: any[]): boolean {\n if (!Array.isArray(array)) return false;\n\n return values.every(value => array.indexOf(value) === -1);\n}\n\n/**\n * Checks if array does not contain any of the given values.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayNotContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_NOT_CONTAINS,\n constraints: [values],\n validator: {\n validate: (value, args): boolean => arrayNotContains(value, args.constraints[0]),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property should not contain $constraint1 values',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
\No newline at end of file