Created
December 1, 2019 17:32
-
-
Save PaulRBerg/836d332dd61708c94caf9ea02326ee03 to your computer and use it in GitHub Desktop.
Custom type checking function for the typy library
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
const { t, addCustomTypes } = require("typy"); | |
addCustomTypes({ | |
isDeepTruthy: input => { | |
const keys = Object.keys(input); | |
for (let i = 0; i < keys.length; i += 1) { | |
const ownProperty = input[keys[i]]; | |
console.log({ i, ownProperty }); | |
if (t(ownProperty).isFalsy) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment