deo icon indicating copy to clipboard operation
deo copied to clipboard

Support alternative verbose syntax

Open wilmoore opened this issue 10 years ago • 7 comments

This is a proposal for a potential enhancement to the syntax.

The short syntax is great; however, for those that need it, the verbose syntax would support:

  • Coercion
  • Validation
  • Alternative Key Name

Example:

var toBoolean = require('truthy')
var isBoolean = require('util').isBoolean

module.exports = deo({
  server: {
    cors: {
      default: true,
      coerce: toBoolean,
      check: isBoolean,
      key: 'CORS_ENABLED'
    }
  }
})

wilmoore avatar Jan 12 '16 20:01 wilmoore

What are your thoughts on https://github.com/hapijs/joi. Is this something that we potentially want to leverage?

vesln avatar Jan 13 '16 07:01 vesln

+1 on joi

korbin avatar Jan 13 '16 16:01 korbin

I use Joi and I think it's great in the right context but think it would be overkill for this. On the other hand, I do realize there are some users that would prefer such a thing as some may not be aware how easy it is to validate a simple value or two.

I dunno...I'm torn. I'd lean toward keeping it lean to start and provide examples then if we still need it, perhaps look into adding it.

wilmoore avatar Jan 13 '16 16:01 wilmoore

Thoughts on the key names proposed? Any other suggestions to bat around?

wilmoore avatar Jan 13 '16 17:01 wilmoore

+1 on joi

RStankov avatar Jan 15 '16 17:01 RStankov

I have no issue with Joi; however, do consider that if we require it, we can no longer in good conscience call this lightweight

wilmoore avatar Jan 15 '16 17:01 wilmoore

Or, minimalistic rather

wilmoore avatar Jan 15 '16 17:01 wilmoore