Skip to content

Unexpected Pattern Validation works when using Controller #1811

Answered by bluebill1049
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

you are missing defautltValue at Controller

<Controller
        name="firstName"
        placeholder="first name"
        defaultValue=""
        as={MyInput}
        rules={{
          pattern: {
            value: /^john$/,
            message: "firstName is invalid"
          }
        }}
        control={control}
      />

the behavior is expected and consistent.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bluebill1049
Comment options

@ghost
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant