Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Created December 1, 2019 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/836d332dd61708c94caf9ea02326ee03 to your computer and use it in GitHub Desktop.
Save PaulRBerg/836d332dd61708c94caf9ea02326ee03 to your computer and use it in GitHub Desktop.
Custom type checking function for the typy library
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