z0mt3c / node-restify-validation

Validation for REST Services built with node-restify in node.js
MIT License
91 stars 49 forks source link

validate empty string #42

Open MichaelIT opened 8 years ago

MichaelIT commented 8 years ago

hi,I need to validate a value not a empty string,but it is no required,can somebody tell me how to do that.

{ meeting_register_begin:{ isRequired: false, isDate:true, not:/^$/ } }

I try to use not , but it does not work.I want to do that because it will cause error in database query when this datetime value is empty string.

gchauvet commented 8 years ago

did you try "notRegex" ?

{ meeting_register_begin:{ isRequired: false, isDate:true, notRegex:/^$/ } }
MichaelIT commented 8 years ago

@gchauvet tks u reply

i try to change my validation from

{ meeting_register_begin:{ isRequired: false, isDate:true, not:/^$/ } }

to

meeting_register_begin:{ isRequired: false, isDate:true, notRegex:/^$/ }

but i still get meeting_register_begin in my logic part of my code.And it was still a empty string.

gchauvet commented 8 years ago

Sorry for my lack of time, I take a look ASAP