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

Form: Validation Rules of type regexp do not work (TypeScript) #10335

Closed
1 task done
k3flo opened this issue May 2, 2018 · 1 comment
Closed
1 task done

Form: Validation Rules of type regexp do not work (TypeScript) #10335

k3flo opened this issue May 2, 2018 · 1 comment

Comments

@k3flo
Copy link

k3flo commented May 2, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.4.1

Environment

react 16.2.0, antd 3.4.1

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Type any character in the input box

What is expected?

The validation should fail, because the regex only allows numbers

What is actually happening?

The validation succeeeds although the regex should fail

@afc163
Copy link
Member

afc163 commented May 2, 2018

          {getFieldDecorator("testNumber", {
            rules: [
              {
                required: true,
-               type: "regexp",
                pattern: new RegExp("^[0-9]*$"),
                message: "Wrong format!"
              }
            ]
          })(<Input />)}

https://codesandbox.io/s/w09xl68pnw

@afc163 afc163 closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants