Skip to content

Fix typing for optional#765

Merged
gustavohenke merged 6 commits intoexpress-validator:masterfrom
connorjayfitzgerald:master
Aug 29, 2019
Merged

Fix typing for optional#765
gustavohenke merged 6 commits intoexpress-validator:masterfrom
connorjayfitzgerald:master

Conversation

@connorjayfitzgerald
Copy link
Copy Markdown
Contributor

There's a bug in the typings when marking a field as optional.
For example, this flags as an error

checkSchema({
  foo: {
    optional: {
      options: {
        nullable: true,
        checkFalsy: true,
      }
    }
  }
})

but allows the following:

checkSchema({
  foo: {
    optional: {
      nullable: true,
      checkFalsy: true,
    }
  }
})

However, this has no effect.

This has been addressed previously in #693 but it looks like this has been regressed.

Also see #742

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 19, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 4bb3816 on connorjayfitzgerald:master into d072629 on express-validator:master.

Copy link
Copy Markdown
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

nullable: false,
});

expect(chainToContext(schema[1]).optional).toEqual({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed to your fork this change to the test, so it's a bit more useful!

@gustavohenke gustavohenke merged commit 7424bfc into express-validator:master Aug 29, 2019
@gustavohenke
Copy link
Copy Markdown
Member

Hello! This is out with v6.2.0! 🚢

@lock
Copy link
Copy Markdown

lock Bot commented Oct 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants