@maioradv/nestjs-core 1.8.4 → 1.8.5

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.
@@ -6,7 +6,11 @@ class Slugger {
6
6
  this.word = word;
7
7
  }
8
8
  get() {
9
- return this.word.trim().normalize("NFD").replace(/[\u0300-\u036f]/g, '').replace(/[^a-z0-9\s]/gi, '').replaceAll(' ', '-').toLowerCase() + (this.unique ? '-' + this.randomString(5) : '');
9
+ return this.word.trim()
10
+ .normalize("NFD").replace(/[\u0300-\u036f]/g, '') // no accent
11
+ .replace(/[^a-z0-9\s]/gi, '') // no special except space
12
+ .replaceAll(' ', '-')
13
+ .toLowerCase() + (this.unique ? '-' + this.randomString(5) : '');
10
14
  }
11
15
  makeUnique() {
12
16
  this.unique = true;
@@ -1 +1,2 @@
1
1
  export * from './image-pipe.validator';
2
+ export * from './is-slug.validator';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./image-pipe.validator"), exports);
18
+ __exportStar(require("./is-slug.validator"), exports);
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+ export declare function IsSlug(validationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsSlug = IsSlug;
4
+ const class_validator_1 = require("class-validator");
5
+ function IsSlug(validationOptions) {
6
+ return function (object, propertyName) {
7
+ (0, class_validator_1.registerDecorator)({
8
+ name: 'IsSlug',
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ options: validationOptions,
12
+ validator: {
13
+ validate(value, args) {
14
+ const regex = /^[a-z0-9-]+$/;
15
+ return typeof value === 'string' && regex.test(value) && value.length > 2;
16
+ },
17
+ },
18
+ });
19
+ };
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maioradv/nestjs-core",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "NestJS helpers by MaiorADV",
5
5
  "repository": "https://github.com/maioradv/nestjs-core.git",
6
6
  "author": "Maior ADV Srl",