Skip to content

Commit

Permalink
Merge pull request #34 from fga-eps-mds/hotfix/form-validation
Browse files Browse the repository at this point in the history
Hotfix/form validation
  • Loading branch information
guilherme1guy committed Oct 29, 2021
2 parents 77268a4 + b8b3d8a commit 7469f13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/questionario/questionario.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ export class QuestionService {

// verify regex
for (const answer of surveyResponse.answers) {
const question = await this.questionModel.findOne({
id: answer.questionId,
});
const question = await this.questionModel.findById(answer.questionId);

const regex = new RegExp(question.validationRegex);
sentFields.add(question.id);

Expand Down
8 changes: 2 additions & 6 deletions test/questionario/questionario.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ describe('QuestionService', () => {
sort: () => result,
};
},
findOne: (data) => {
findById: (id) => {
return defaultData.filter((element) => {
return element['id'] === data['id'];
return element['id'] === id;
})[0];
},
},
Expand All @@ -105,10 +105,6 @@ describe('QuestionService', () => {
questionId: '1',
response: 'Joao',
},
{
questionId: '2',
response: 'Ricardo',
},
],
};

Expand Down

0 comments on commit 7469f13

Please sign in to comment.