DEV Community

Agik Setiawan
Agik Setiawan

Posted on • Edited on

17 4

validation password and confirm password with Yup

Yup is javascript schema builder for validation like string, number, password, etc.

use yup for validation password and confirm password very easy with yup schema like below

import * as Yup from "yup";

const validation = Yup.object().shape({
    email: Yup.string().required().email(),
    name: Yup.string().required(),
    phone: Yup.string().required(),
    password: Yup.string().required(),
    confirm_password: Yup.string().label('confirm password').required().oneOf([Yup.ref('password'), null], 'Passwords must match'),
  })

Enter fullscreen mode Exit fullscreen mode

we can use oneOf([Yup.ref('password'), null], 'Passwords must match')

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay