Skip to content

Instantly share code, notes, and snippets.

@martinheidegger
Created August 29, 2014 08:58
Show Gist options
  • Save martinheidegger/b5635ede5b87b905b4ea to your computer and use it in GitHub Desktop.
Save martinheidegger/b5635ede5b87b905b4ea to your computer and use it in GitHub Desktop.
Thoughts about easier joi definitions.
module.exports = Joi.object({
   a: Joi.string()
}).description("");

is a lot to write. It would be cool if it could look like

object({
  a: string()
}).description();

Where the rule is that there is only one line to this syntax (it may contain spaces within braces but not outside them). i.e. this would be invalid

object({
})
object({
})

(here we have a line break after the closing brace in line 2 -> error)

But if its outside of the major braces its okay.

It would be nice to create a verification like

joiful("input.joi")

and perhaps even nicer to have

scopeful("input.joi")

File ending joi tells scopeful to set the scope to require("joi")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment