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

Yup and Formik Validation in React

I have a condition that a certain field is required if the value is either '1', '2', '3', '4'. How can you do this? Pls check my code below travelDate: yup.string().when('planeAvailable', { is: '1' || '2' || '3' || '4', then:…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
0 answers

Reactjs Yup dropdownlist Form Validation

I am doing a form validation in reactjs using YUP. I wrote the form validation as follows - const FromValidation = Yup.object().shape({ nameId: Yup.object() .nullable() .required('name is requried'), classId: Yup.object() …
coddey
  • 390
  • 2
  • 13
0
votes
2 answers

Formik React-Native - How to Show Yup Validation Errors on Each Field in an Array of Objects

So I'm trying to make a list of contacts, here's the code: Yup Schema: export const Schema = Yup.object().shape({ /**other fields */ contacts: Yup.array().required('Required field').of( Yup.object().required('Required!').shape({ id:…
0
votes
1 answer

Validation with Yup doesn't show the correct message

I'm using Yup and Formik to validate some fields. One of the must be a number so this is how it was done: import * as Yup from 'yup'; ... const requiredErrorMessage = 'This field is required'; const numberErrorMessage = 'This field is must be…
Leo Messi
  • 5,157
  • 14
  • 63
  • 125
0
votes
1 answer

Object validation using formik and yup

here is my object. food:{ veg:{ name:, price: }, non_veg:{ name:, price: } } how to validate the object, as there is options for array validation only.
suvop
  • 31
  • 5
0
votes
1 answer

Label transition is not working in case of validations with React-hook-form

I am trying to apply a styling which moves the label to top when the input is in focus. It was working very well before I tried to add validation. Sample Code:-
0
votes
1 answer

Update specific value in Initial Values Formik

I am using Formik and Yup validation for my form which has firstname ,lastname & username. Username should be without spaces so I am using a onChange event and value. Yup validation is working for firstname and Lastname but not for username. When…
M. Saran
  • 13
  • 1
  • 6
0
votes
1 answer

Formik + Yup - Show error as user is typing in

I have an email field and I am validating its uniqueness as the user types in i.e is the email the user is typing available. Currently, I only get the error message when the user loses focus of the field (onBlur) but I want formik to show errors…
mikasa
  • 783
  • 1
  • 11
  • 29
0
votes
1 answer

Formik Yuk - remove required message

Is there a way to make formik field required but not showing no error message? Even by removing any string from string.required(), Yup stills shows a default error. validationSchema={Yup.object().shape({ FirstName: Yup.string() …
Jim_Mcdonalds
  • 426
  • 5
  • 15
0
votes
1 answer

Autocomplete Set Default Value in React

I need to have a default value in my autocomplete in my react app. My problem is when i try to submit it, it still is invalid. Meaning it has no value in it. I need to click the autocomplete and select it again just to make to have the value. Pls…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
4 answers

Formik / Yup Validation for Register Form on React

I am learning react and I have decided to create a React Front End that connects to Express.js on back-end. At the moment, I am trying to add validation on my register/login forms. I dont really understand how the validation system is implemented.…
H T
  • 1
  • 1
  • 5
0
votes
1 answer

Formik adds new Array of value instead of adding only the value

I have a form that consists of cards where the user needs to select the derised ones. This form uses the useFormik hook and yup for validation. The code looks like so: Declaration of formik in a form.tsx export const validationSchema =…
PmmZenha
  • 155
  • 2
  • 9
0
votes
1 answer

Is there a way to require a field based on another field using a Yup schema?

I have a title (input field) and a checkbox. I've successfully implemented a schema to require the checkbox on its own. What I want to do is, validate if something has been typed in the title, if it's empty then the checkbox is required. I tried…
Fresh Java
  • 107
  • 1
  • 10
0
votes
1 answer

How can I make a picker in react native required

I have created a signup form in react native with formik and yup.According to the documentation I have added the react native picker.
Sahan Randika
  • 47
  • 1
  • 14
0
votes
1 answer

Condition Validation Yup- Any one field is required (Error: Uncaught Error: Cyclic dependency, the node was: "b".)

In my application I'm using Yup validation. I faced a scenario where I need at least one of the three fields(String) required. I've tried using the below code but it is throwing Uncaught Error: Cyclic dependency, the node was: "b". a:…
dinesh dsv
  • 13
  • 1
  • 4
1 2 3
99
100