Skip to content

Instantly share code, notes, and snippets.

@glommer
Last active June 15, 2022 12:05
Show Gist options
  • Save glommer/335696423126c2634fa6855f1a347688 to your computer and use it in GitHub Desktop.
Save glommer/335696423126c2634fa6855f1a347688 to your computer and use it in GitHub Desktop.
// Validating emails with email-validator.
// Validation happens inline, straight inside the arrow function
const user = await User.findOne(user => user.name == "Glauber Costa" &&
user.age >= 40 &&
validate(user.email));
return new Response(user?.email ?? "not found");
// Same code, but now splitting database and runtime code out-of-line.
// The results are equivalent in ChiselStrike.
const user = await User.findOne(user => user.name == "Glauber Costa" && user.age >= 40);
return new Response(validate(user?.email) ? user.email : "not found");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment