Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: updated package json #287

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,23 @@ export class IssuanceService {
throw new BadRequestException(`File header is empty`);
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const validateEmail = (email) => {
// Regular expression for a simple email validation
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailRegex.test(email);
};

// Extract and validate emails
const invalidEmails = parsedData.data.filter((entry) => !validateEmail(entry.email));

// Output invalid emails
if (0 < invalidEmails.length) {

throw new BadRequestException(`Invalid emails found in the chosen file`);

}

const fileData: string[] = parsedData.data.map(Object.values);
const fileHeader: string[] = parsedData.meta.fields;

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@nestjs/axios": "^3.0.0",
"@nestjs/bull": "^10.0.1",
"@nestjs/cache-manager": "^2.1.0",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^10.1.3",
Expand Down Expand Up @@ -55,6 +56,8 @@
"body-parser": "^1.20.1",
"buffer": "^6.0.3",
"bull": "^4.11.4",
"cache-manager": "^5.2.4",
"cache-manager-redis-store": "^2.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"crypto-js": "^4.1.1",
Expand Down
Loading