question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

optional: false not work

See original GitHub issue
req.checkBody({
  'name.first': { //
    optional: false, // won't validate if field is empty
    isLength: {
      options: [2, 10],
      errorMessage: 'Must be between 2 and 10 chars long' // Error message for the validator, takes precedent over parameter message
    },
    errorMessage: 'Invalid First Name'
  }
});

it seems optional: false not work.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
srkimircommented, Jun 25, 2016

@ViswanathGavva can you please try with:

email: {
  optional: {
    options: [{ checkFalsy: true }]
  }
}
3reactions
ViswanathGavvacommented, Mar 7, 2016

Thanks for the Reply. But the above does not work in schema validation. Below does not work.

‘email’: { optional: { checkFalsy:true }, isEmail:{ errorMessage: ‘Invalid Email’ } }

But the below is working as expected.

req.checkBody(‘email’,‘Enter Valid Email’).optional({checkFalsy:true}).isEmail();

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate: one-to-one lazy loading, optional = false
Although I used LAZY fetchType but it seems doesn't work. When I put optional=false , it works. Any explanation will be appreciated really....
Read more >
JPA - Making @OneToOne relationship mandatory by setting ...
For a mandatory association, the target entity cannot be persisted when it's associated reference is null. The default value of 'optional' element is...
Read more >
@ManyToOne(optional=false) and @JoinColumn(nullable ...
Best Answer​​ Hello, The optional and nullable options are hints to the JPA provider that are used during DDL generation. TopLink Essentials does...
Read more >
@ManyToOne(optional=false) and @JoinColumn (nullable ...
My serial number for adobe photoshop elements 12 and first 12 items does not work. On adobe.com, it shows that I received the...
Read more >
ManyToOne(optional=false) creates a nullable field in DDL
Bug 251201 - @ManyToOne(optional=false) creates a nullable field in DDL ... is: CREATE TABLE OrderInfo (ID NUMBER(19) NOT NULL, VERSION NUMBER(19) NULL, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found