@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()
|
|
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;
|
package/dist/validators/index.js
CHANGED
|
@@ -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
|
+
}
|