Skip to content

Commit

Permalink
Return true or false correctly from formIsValid #6898
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 authored and sc0ttkclark committed Apr 25, 2023
1 parent 8e6286d commit ab3ced8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ui/js/dfv/src/pods-dfv.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ window.PodsDFV = {
* @param {int|null} itemId Object ID. (Optional.)
* @param {int|null} formCounter Form index. (Optional.)
*
* @return {string[]|undefined} List of validation messages, or undefined if not found.
* @return {Object.<string, string[]>} Returns field names as keys and arrays of validation messages as values.
*/
getValidationMessages( pod = null, itemId = null, formCounter = null ) {
const form = this.detectForm(
Expand All @@ -625,9 +625,6 @@ window.PodsDFV = {
// Get validation messages.
const validationMessages = form.stored.getValidationMessages();

// Debug output for validation messages for now. @todo Remove this.
console.log( { validationMessages } );

return validationMessages;
},

Expand All @@ -647,7 +644,16 @@ window.PodsDFV = {
return undefined;
}

return 0 === validationMessages.length;
if ( 0 === Object.keys( validationMessages ).length ) {
return false;
}

return Object.values( validationMessages ).every( ( messages ) => {
if ( 0 !== messages.length ) {
return false;
}
return true;
} );
},

/**
Expand Down

0 comments on commit ab3ced8

Please sign in to comment.