diff --git a/src/helpers/helpers.ts b/src/helpers/helpers.ts index be299fbe..c357580f 100644 --- a/src/helpers/helpers.ts +++ b/src/helpers/helpers.ts @@ -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;