Answers for "yup validation"


yup password validation

import * as Yup from 'yup';

validationSchema: Yup.object({
  password: Yup.string().required('Password is required'),
  passwordConfirmation: Yup.string()
     .oneOf([Yup.ref('password'), null], 'Passwords must match')
Posted by: Guest on January-15-2020

yup only characters regex validation react

   .required("Please enter the required field")
   .matches(/^[aA-zZs]+$/, "Only alphabets are allowed for this field ")
Posted by: Guest on September-29-2020

yup npm

npm i yup --save
Posted by: Guest on June-20-2020

yup oneOf

// mixed.oneOf(arrayOfValues: Array<any>, message?: string | function): Schema Alias: equals
// Whitelist a set of values. Values added are automatically removed from any blacklist if they are in it. The ${values} interpolation can be used in the message argument.

// Note that undefined does not fail this validator, even when undefined is not included in arrayOfValues. If you don't want undefined to be a valid value, you can use mixed.required.

let schema = yup.mixed().oneOf(['jimmy', 42]);

await schema.isValid(42); // => true
await schema.isValid('jimmy'); // => true
await schema.isValid(new Date()); // => false
Posted by: Guest on November-24-2020

Browse Popular Code Answers by Language