Questions tagged [yup]

Yup is a JavaScript object schema validator and object parser based on Joi

Yup is a JavaScript object schema validator and object parser. The API and style is inspired by Joi.

Yup is leaner than Joi: in the same spirit, without some of the fancy features. You can use it on the server as well, but in that case you might as well just use Joi.

Yup is also a good bit less opinionated than joi, allowing for custom transformations and async validation. It also allows "stacking" conditions via when for properties that depend on more than one other sibling or child property. Yup separates the parsing and validating functions into separate steps so it can be used to parse json separate from validating it, via the cast method.

Documentation and source can be found on the yup github page

1580 questions
0
votes
1 answer

Formik, Yup, formik-material-ui sign up form showing email error when the form is clicked

I have a sign up form built with Formik, Yup and formik-material-ui: If I click anywhere on the form it shows the email error, meaning if the user clicks on 'Already have an account? Sign In', the form shows this error rather than redirecting to…
AngularBoy
  • 1,715
  • 2
  • 25
  • 35
0
votes
1 answer

How to chain on custom validations using Yup

I want to add a .test() method to a validationSchema. The test is to look for common email domain misspellings. For instance, to check if gmail was misspelled "gmial" or "gnail". const validationSchema = Yup.object({ email:…
jll9qw
  • 11
0
votes
1 answer

Formik + Yup, array being converted to object and then failing validation

I have an array of filters with the following Yup schema: const schema = Yup.object().shape({ filters: Yup.array().strict().of( Yup.array().strict().of( Yup.object().shape({ // This isn't important }) ) ) }); When I…
Migwell
  • 18,631
  • 21
  • 91
  • 160
0
votes
1 answer

go to next step only when validation pass

I have a wizard form where I need to check if there is any validation issue on each step so that if there is an issue then don't allow user to go to next step unless there is no validation error. On this check, I am facing an issue. The issue is, on…
Serenity
  • 3,884
  • 6
  • 44
  • 87
0
votes
0 answers

How to change the Formik validation Programatically

i am stuck on one point on the formik while creating the validations. I have one object inside that i have 5 values . which are boolean subs = { math = true, science = true, computer= true, medical = true, g.k = true } i have an input filed for…
Night owl
  • 145
  • 10
0
votes
1 answer

Yup date min doesn't work with Formik DatePicker

I'm using yup validationSchema for Formik, however, when I'm trying to validate date, it doesn't work, validation for all other fields work correctly. What I'm doing wrong? const formSchema = yup.object({ startsAt:…
Lucky_girl
  • 4,543
  • 6
  • 42
  • 82
0
votes
1 answer

How do I check if my string ends with WA followed by 9 digit

I want to validate my string input with regx in typescript/javascript. string input is 9 digit followed by WA I tried using below two Regx, its able to validate digit part, but couldn't validate end of string to be WA. val.matches('^[0-9]') &&…
Krunal Parmar
  • 491
  • 2
  • 19
0
votes
1 answer

Formik Trying to Validate Invisible Fields

I am running into this issue with Formik Validation Schema. My form has 3 shapes it takes and a few fields that are present in each shape depending on the given params type and upperType. The issue is when I try submit my form if one of the below…
Haq.H
  • 863
  • 7
  • 20
  • 47
0
votes
1 answer

How to validate an array of numbers when a boolean is false?

I need to validate an array of numbers when a boolean is checked and i'm getting this error in console: Uncaught (in promise) TypeError: Cannot read property 'length' of undefined at yupToFormErrors (formik.esm.js:701) and this is my yup…
0
votes
0 answers

How to validate a nested and conditionally optional Yup schema

I'm facing a problem when i'm trying to validate a nested schema with Yup(). My cenary is, i have the following payload (that may not always contain maxAge and maxAge, but at least one of them): { name: 'userName', calc: [{ maxAge:{ …
bsantoss
  • 427
  • 6
  • 17
0
votes
1 answer

Displaying errors simultaneously writing in an input

I've been using Yup and Formik for form validation in React. Now when a user blurs an input then, errors are displayed. Here is my code: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa import React from "react"; import {…
S. Hesam
  • 5,266
  • 3
  • 37
  • 59
0
votes
1 answer

Adding icon to text field based on server side validation(Formik+Yup+Material UI)

I am trying to show a tick or cross icon in a text field based on the api response. My text field looks like this. I've added inputProps to it and added an adornment. But I want to display different icons based on a function which will return if its…
Shehzadi khushi
  • 275
  • 1
  • 4
  • 20
0
votes
1 answer

How to set validation schema based on condition using Yup? Formik

I'm trying to use Yup to validate data in an array. For example, this is my initialValue: {name:'',extra:[]} After dynamic render the form field , the initialValue will become like this: {name:'',extra:[{label:'age',value:'',required:true}]} I…
wkwkwk
  • 310
  • 5
  • 13
0
votes
3 answers

How to validate an object with a key inside it in Yup Validation

This is a snippet in my React application using Formik. My initial value is initialValues: { country: { label: '', value: '' } } My field input is country which is a Select option and its value when selected will be as country: { label:…
Hareesh
  • 1,507
  • 3
  • 21
  • 43
0
votes
2 answers

onChange on TextInput Not Working Inside Formik

Generally allows you to type even when you're just specifying a placeholder. However, when using within the Formik form, I am unable to type and validate anything in my form. What am I doing wrong? I have tried onChangeTextwith…
user12541823
1 2 3
99
100