mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-20 22:52:39 +02:00
fix: update condition for checking signature widget validation
This commit is contained in:
@@ -88,20 +88,11 @@ export default async function createDocumentWithTemplate(request, response) {
|
||||
const updateSigners = placeholder.every(y => signers?.some(x => x.role === y.Role));
|
||||
// console.log('isValid ', isValid);
|
||||
if (isValid && updateSigners) {
|
||||
let isSignExist = false; // variable is used to check a signature widget exit or not then execute other code
|
||||
//for loop is used to check signature widget exist or not
|
||||
parent: for (let item of template?.Placeholders) {
|
||||
// Reset for each iteration
|
||||
for (let x of item?.placeHolder) {
|
||||
if (!isSignExist) {
|
||||
isSignExist = x.pos.some(data => data?.type === 'signature');
|
||||
if (isSignExist) {
|
||||
break parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isSignExist) {
|
||||
//Check if every item's placeholders contain at least one placeholder with type 'signature'.
|
||||
let isSignature = template?.Placeholders?.every(item =>
|
||||
item?.placeHolder.some(x => x?.pos.some(data => data?.type === 'signature'))
|
||||
);
|
||||
if (!isSignature) {
|
||||
return response
|
||||
.status(400)
|
||||
.json({ error: 'Please add at least one signature widget for all signers' });
|
||||
|
||||
@@ -88,13 +88,10 @@ export default async function createDocumentwithCoordinate(request, response) {
|
||||
objectId: parseUser.userId.objectId,
|
||||
};
|
||||
if (signers && signers.length > 0) {
|
||||
//for loop is used to check signature widget exist or not
|
||||
let isSignExist = true; // Reset for each iteration
|
||||
for (let item of signers) {
|
||||
if (!isSignExist) {
|
||||
signatureExist = item.widgets.some(data => data?.type === 'signature');
|
||||
}
|
||||
}
|
||||
// Check if at least one signature exists among all items in the signers array
|
||||
let isSignExist = signers.every(item =>
|
||||
item.widgets.some(data => data?.type === 'signature')
|
||||
);
|
||||
if (!isSignExist) {
|
||||
return response
|
||||
.status(400)
|
||||
|
||||
Reference in New Issue
Block a user