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

Version 1.5.0 #39

Merged
merged 1 commit into from
Feb 18, 2025
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
16 changes: 11 additions & 5 deletions src/controllers/ContactController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ import { ContactFunction } from '../entity/enums/ContactFunction';
@Tags('Contact')
export class ContactController extends Controller {
private async validateContactParams(req: express.Request) {
const emailOptionalFunctions = [
ContactFunction.SIGNATORY_AUTHORIZED,
ContactFunction.ASSISTING,
ContactFunction.OLD,
];
await validate([
body('gender').isIn(Object.values(Gender)),
body('firstName').trim(),
body('lastNamePreposition').optional({ checkFalsy: true }).isString().trim(),
body('firstName').optional({ values: 'falsy' }).isString().trim(),
body('lastNamePreposition').optional({ values: 'falsy' }).isString().trim(),
body('lastName').notEmpty().trim(),
body('email').isEmail().normalizeEmail(),
body('telephone').optional({ checkFalsy: true }).isMobilePhone('any'),
body('comments').optional({ checkFalsy: true }).isString().trim(),
body('telephone').optional({ values: 'falsy' }).isMobilePhone('any'),
body('comments').optional({ values: 'falsy' }).isString().trim(),
body('companyId').isInt(),
body('function').isIn(Object.values(ContactFunction)),
body('email').if(body('function').not().isIn(emailOptionalFunctions)).notEmpty().isEmail().normalizeEmail(),
body('email').if(body('function').isIn(emailOptionalFunctions)).optional({ values: 'falsy' }).isEmail().normalizeEmail(),
], req);
}

Expand Down
2 changes: 2 additions & 0 deletions src/entity/enums/ContactFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ export enum ContactFunction {
PRIMARY = 'PRIMARY',
FINANCIAL = 'FINANCIAL',
OLD = 'OLD',
SIGNATORY_AUTHORIZED = 'SIGNATORY_AUTHORIZED',
ASSISTING = 'ASSISTING',
}
4 changes: 2 additions & 2 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ const models: TsoaRoute.Models = {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"ContactFunction": {
"dataType": "refEnum",
"enums": ["NORMAL","PRIMARY","FINANCIAL","OLD"],
"enums": ["NORMAL","PRIMARY","FINANCIAL","OLD","SIGNATORY_AUTHORIZED","ASSISTING"],
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"Contact": {
Expand Down Expand Up @@ -760,7 +760,7 @@ const models: TsoaRoute.Models = {
"firstName": {"dataType":"string"},
"lastNamePreposition": {"dataType":"string"},
"lastName": {"dataType":"string","required":true},
"email": {"dataType":"string","required":true},
"email": {"dataType":"string"},
"telephone": {"dataType":"string"},
"comments": {"dataType":"string"},
"companyId": {"dataType":"double","required":true},
Expand Down
2 changes: 1 addition & 1 deletion src/services/ContactService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ContactParams {
firstName?: string;
lastNamePreposition?: string;
lastName: string;
email: string;
email?: string;
telephone?: string;
comments?: string;
companyId: number;
Expand Down