node-restify-validation icon indicating copy to clipboard operation
node-restify-validation copied to clipboard

validate empty string

Open MichaelIT opened this issue 9 years ago • 3 comments

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.

MichaelIT avatar Apr 26 '16 02:04 MichaelIT

did you try "notRegex" ?

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

gchauvet avatar Apr 27 '16 08:04 gchauvet

@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.

MichaelIT avatar Apr 27 '16 10:04 MichaelIT

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

gchauvet avatar May 30 '16 14:05 gchauvet