← Back to Home

Form Using Yup Validation

See the source code

Use +62 format

Choose date greater than 15/08/2020

Yup Schema:

  name: yup.string().required('Name is required'),
  email: yup
    .email('Need to be a valid email')
    .required('Email is required'),
  password: yup
    .required('Password is required')
    .min(8, 'Password must be at least 8 characters long'),
  age: yup
    .number('Must be a number')
    .typeError('Must be a number')
    .positive('Must be a positive value')
    .integer('Must be a number')
    .required('Age is required'),
  phone: yup
    .matches(/^+628[1-9][0-9]{8,11}$/, 'Must use +62 format')
    .required('Phone is required'),
  personalsite: yup
    .url('Must be a url')
    .required('Personal Site is required'),
  date: yup
    .min(new Date('2020-08-15'), 'Date must be greater than 15/08/2020')
    .required('Date is required'),