talyssonoc / structure

A simple schema/attributes library built on top of modern JavaScript

Home Page:https://structure.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

validation for empty strings

kissmygritts opened this issue · comments

Was the api changed between 1.2.1 to 1.2.0 to set the default of empty to false? And should it default to true? If required defaults to false, is the assumption is that that prop isn't included in the object on creation? Then if it is included in the object on creation but is left blank validation will fail. It isn't a huge deal, I'm curious about your thinking on this issue. Thanks for the help.

https://structure.js.org/docs/validation.html#string-validations

The API was not changed but this is a behavior inherited from Joi that by default does not allow empty strings.

I don't think it should default to true, It really depends on the project you are working on, me for example, I'm working on a project using DynamoDB and it doesn't allow empty so for us it's a good behavior.

But I think a generic way to set configurations like that would be great then I proposed that feature.