This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adjusts namespaces and call signatures of "isValid" utils
- Loading branch information
1 parent
96a63ea
commit 8dd1349
Showing
4 changed files
with
24 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
function isValidComponent(errors) { | ||
/** | ||
* Concludes HTTP message's component validity based on the given | ||
* list of validation errors. | ||
* @param {Object<string, any>} errors | ||
* @returns {boolean} | ||
*/ | ||
function isValidField({ errors }) { | ||
return errors.length === 0; | ||
} | ||
|
||
// Returns a boolean indicating whether a given validation result | ||
// concludes two HTTP messages as valid (matching). | ||
// Separated into its own util only to be used in both next and legacy API. | ||
function isValid(validationResult) { | ||
return Object.values(validationResult.fields).every((resultGroup) => { | ||
return isValidComponent(resultGroup.errors); | ||
}); | ||
/** | ||
* Returns a boolean indicating the given validation result as valid. | ||
* @param {Object<string, any>} validationResult | ||
* @returns {boolean} | ||
*/ | ||
function isValidResult(validationResult) { | ||
return Object.values(validationResult.fields).every(isValidField); | ||
} | ||
|
||
module.exports = { isValid, isValidComponent }; | ||
module.exports = { | ||
isValidResult, | ||
isValidField | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters