Skip to content

Commit

Permalink
Handle validations
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Sep 30, 2024
1 parent 7f979c4 commit 8d21458
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IdentityServiceStrategySetup } from '../../services/identity/index.js';
import { AccreditationService } from '../../services/api/accreditation.js';
import { Credentials } from '../../services/api/credentials.js';
import { eventTracker } from '../../services/track/tracker.js';
import { body, query } from '../validator/index.js';
import { body, query, validationResult } from '../validator/index.js';

export class AccreditationController {
public static issueValidator = [
Expand Down Expand Up @@ -106,6 +106,14 @@ export class AccreditationController {
* $ref: '#/components/schemas/InternalError'
*/
public async issue(request: Request, response: Response) {
const result = validationResult(request);
if (!result.isEmpty()) {
return response.json({
code: -13,
message: result.array()[0].msg,
});
}

// Get strategy e.g. postgres or local
const identityServiceStrategySetup = new IdentityServiceStrategySetup();
// Extract did from params
Expand Down Expand Up @@ -318,6 +326,14 @@ export class AccreditationController {
* $ref: '#/components/schemas/InternalError'
*/
public async verify(request: Request, response: Response) {
const result = validationResult(request);
if (!result.isEmpty()) {
return response.json({
code: -13,
message: result.array()[0].msg,
});
}

// Extract did from params
let { verifyStatus = false, allowDeactivatedDid = false } = request.query as VerifyCredentialRequestQuery;
const { accreditation, policies, subjectDid } = request.body;
Expand Down

0 comments on commit 8d21458

Please sign in to comment.