@brilab-mailer/utils 0.0.2-0 → 0.0.2-2
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.
- package/decorators/email-field.decorator.d.ts +4 -0
- package/decorators/email-field.decorator.d.ts.map +1 -0
- package/decorators/email-field.decorator.js +7 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.d.ts.map +1 -1
- package/decorators/index.js +1 -0
- package/decorators/is-real-email.decorator.d.ts +1 -1
- package/decorators/is-real-email.decorator.d.ts.map +1 -1
- package/decorators/is-real-email.decorator.js +3 -3
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-field.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/email-field.decorator.ts"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,+IAU1D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { IsEmail, IsNotEmpty, IsString, Matches, MaxLength, } from 'class-validator';
|
|
3
|
+
import { Transform } from 'class-transformer';
|
|
4
|
+
import { IsRealEmail } from './is-real-email.decorator.js';
|
|
5
|
+
export function EmailField(options) {
|
|
6
|
+
return applyDecorators(IsEmail(), IsRealEmail(), IsString(), MaxLength(255), Matches(/^(?!\s*$).+/, { message: 'should not be only spaces' }), ...(options?.required !== false ? [IsNotEmpty()] : []), Transform(({ value }) => (value === '' ? null : value)));
|
|
7
|
+
}
|
package/decorators/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA"}
|
package/decorators/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export declare class IsRealEmailConstraint implements ValidatorConstraintInterfa
|
|
|
3
3
|
validate(email: string): Promise<boolean>;
|
|
4
4
|
defaultMessage(): string;
|
|
5
5
|
}
|
|
6
|
-
export declare function IsRealEmail(validationOptions?: ValidationOptions):
|
|
6
|
+
export declare function IsRealEmail(validationOptions?: ValidationOptions): PropertyDecorator;
|
|
7
7
|
//# sourceMappingURL=is-real-email.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-real-email.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/is-real-email.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAGzB,qBACa,qBAAsB,YAAW,4BAA4B;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM;IAW5B,cAAc;CAGf;AAED,wBAAgB,WAAW,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"is-real-email.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/is-real-email.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAGzB,qBACa,qBAAsB,YAAW,4BAA4B;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM;IAW5B,cAAc;CAGf;AAED,wBAAgB,WAAW,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,CAUpF"}
|
|
@@ -23,10 +23,10 @@ IsRealEmailConstraint = __decorate([
|
|
|
23
23
|
], IsRealEmailConstraint);
|
|
24
24
|
export { IsRealEmailConstraint };
|
|
25
25
|
export function IsRealEmail(validationOptions) {
|
|
26
|
-
return function (
|
|
26
|
+
return function (target, propertyKey) {
|
|
27
27
|
registerDecorator({
|
|
28
|
-
target:
|
|
29
|
-
propertyName:
|
|
28
|
+
target: target.constructor,
|
|
29
|
+
propertyName: String(propertyKey),
|
|
30
30
|
options: validationOptions,
|
|
31
31
|
constraints: [],
|
|
32
32
|
validator: IsRealEmailConstraint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brilab-mailer/utils",
|
|
3
|
-
"version": "0.0.2-
|
|
3
|
+
"version": "0.0.2-2",
|
|
4
4
|
"author": "Bohdan Radchenko <radchenkobs@gmail.com>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@nestjs/common": "^10.0.0",
|
|
28
28
|
"@nestjs/config": "^3.0.0",
|
|
29
|
+
"class-transformer": "^0.5.1",
|
|
29
30
|
"class-validator": "^0.14.2"
|
|
30
31
|
}
|
|
31
32
|
}
|