Skip to content

Commit

Permalink
Fix validation for DidCreatePayload
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Nikitin committed Sep 29, 2023
1 parent 44d1228 commit 8d990bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ export function toDefaultDkg(did: string): DkgOptions {
}

export function validateDidCreatePayload(didDocument: DIDDocument): SpecValidationResult {
if (!didDocument) return { valid: true };

// id is required, validated on both compile and runtime
if (!didDocument.id && !didDocument.id.startsWith('did:cheqd:')) return { valid: false, error: 'id is required' };
if (!didDocument.id || !didDocument.id.startsWith('did:cheqd:')) return { valid: false, error: 'id is required' };

if (!isValidService(didDocument)) return { valid: false, error: 'Service is Invalid' };
return { valid: true } as SpecValidationResult;
Expand Down

0 comments on commit 8d990bd

Please sign in to comment.