This commit is contained in:
Erik 2024-10-13 12:29:20 +03:00
parent 2a39301713
commit a938ade360

View File

@ -44,7 +44,7 @@ export const parseValidationError = (error: MongoServerError) =>
{ {
if (error.code !== 121 || !error.errInfo) if (error.code !== 121 || !error.errInfo)
throw new Error('Not a validation error'); throw new Error('Not a validation error');
const rule = error.errInfo.details.schemaRulesNotSatisfied; const [ rule ] = error.errInfo.details.schemaRulesNotSatisfied;
const missing = rule.missingProperties as string[]; const missing = rule.missingProperties as string[];
const required = rule.specifiedAs.required as string[]; const required = rule.specifiedAs.required as string[];
return { missing, required }; return { missing, required };