Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

username validation formik react yup

validationSchema: Yup.object({
        email: Yup.string()
            .min(8, 'Must be at least 8 characters')
            .max(20, 'Must be less  than 20 characters')
            .required('Email is required')
            .test('Unique Email', 'Email already in use', // <- key, message
                function (value) {
                    return new Promise((resolve, reject) => {
                        axios.get(`http://localhost:8003/api/u/user/${value}/available`)
                            .then((res) => {
                                resolve(true)
                            })
                            .catch((error) => {
                                if (error.response.data.content === "The email has already been taken.") {
                                    resolve(false);
                                }
                            })
                    })
                }
            ),
    }),
Comment

PREVIOUS NEXT
Code Example
Javascript :: falsy values in array 
Javascript :: image not showing js 
Javascript :: angular json pipe pretty 
Javascript :: money separator in javascript 
Javascript :: javascript get text between two strings 
Javascript :: js alert 
Javascript :: pad js 
Javascript :: javascript object first key 
Javascript :: wait one second in javascript using async wait 
Javascript :: javascript load multiple images 
Javascript :: import resolver path react 
Javascript :: JavaScript Using a Temporary Variable 
Javascript :: find element in array javascript 
Javascript :: form submit programmatically 
Javascript :: how to loop object javascript 
Javascript :: system collections generic list to javascript array 
Javascript :: TypeError: getComputedStyle(...).getPropertyValue is not a function 
Javascript :: port 3000 is already in use nodemon app crashed 
Javascript :: how to get back image and front text in react native 
Javascript :: react image 
Javascript :: scroll to div jquery 
Javascript :: vuejs string contains 
Javascript :: moment js year only 
Javascript :: how to return 5 records instead of 10 records in datatable 
Javascript :: print odd numbers in an array in javascript 
Javascript :: ascending val in array using js 
Javascript :: setinterval break 
Javascript :: string to title case javascript 
Javascript :: javascript blur focus active element 
Javascript :: eliminar el ultimo caracter de un string javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =