Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for optional #765

Merged
merged 6 commits into from
Aug 29, 2019

Conversation

connorjayfitzgerald
Copy link
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

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
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!!

checkFalsy: false,
nullable: false,
});

expect(chainToContext(schema[1]).optional).toEqual({
Copy link
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
Member

Hello! This is out with v6.2.0! 🚢

@lock
Copy link

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.

None yet

3 participants