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
2 answers

Only allow ASCII characters in Email Validation with YUP

I'm using React and Yup to validate an email address. My schema looks like this: const registrationSchema = yup.object().shape({ email: yup.string().email().required() }) And my code like this: const handleOnSubmit = async () => { const…
Alfrex92
  • 6,278
  • 9
  • 31
  • 51
0
votes
1 answer

React-Hooks-Form v 6.x.x with YUP not resolves all validation

I am using Ionic with React. To build my forms I use react-hooks-form version 6.x.x. I defined a Yup object for validation, like this: const validationSchema = object().shape ({ email: string() .required("A mező kitöltése kötelező!") …
Wasyster
  • 2,279
  • 4
  • 26
  • 58
0
votes
0 answers

How to set up yup validation conditionals?

I have a set of data that i'm tring to validate; It have two fields: "citiesProvided" and "servicesProvided" they are dependent of "LegalCorrespondenceService" that is a array with just one string with the value "true" or "false" Like represented…
0
votes
1 answer

how to do setTimeout on Yup.test?

i am trying to validate an address: line1: Yup.string() .test( "Address Line 1 Validation Test", "Please enter valid Line 1 address", async (line1: string) => { let delayTimer = null; let isValid = false; …
gpbaculio
  • 5,693
  • 13
  • 60
  • 102
0
votes
1 answer

Formik disabled submit btn

I have Formik form where initialValues are not empty for all fields. I have the following condition on my submit button: disabled={!(dirty && isValid)} Yup validation schema: const signInSchema = Yup.object().shape({ title: Yup.string() …
0
votes
1 answer

my form is not working. when i click on save button, my table is blank, without the field input.and my cancel button is not clearing the fields

I'm using React, Formik and Yup to make a form. my form is not working. when i click on save button, my input is not saving the information I typed on the fields. it's saving blank information on the table. and my cancel button is not clearing the…
0
votes
1 answer

Use server date instead of new Date() in React

I have minimum date and maximum date control on more than one page on the yup side. My login service returns processDate: 12.26.2020 response and I want to pass the processDate parameter instead of using new Date() to all controls. How should I go?…
friomorte
  • 17
  • 2
0
votes
1 answer

Yup.string.when will always give the result undefined. How can i pass a string value into the .when method

below my code. For some reason, the iscountrycode is undefined when I put it into the .when. in the console.log the result is 'BE' export function getCheckoutFormSchema(t?: any, iscountryCode?: string) {` console.log(iscountryCode)` let…
Bert
  • 3
  • 2
0
votes
1 answer

React Yup schema

I'm using Yup to validate an email field: const Schema = Yup.object().shape({ email: Yup.string() .email("non valid email format") .required("Email required"), ... During form submit, I check if the email domain is included in a list of…
Malakiof
  • 98
  • 6
  • 18
0
votes
1 answer

Validate dates then transfer it to iso string react

My problem is that I need to validate my date using any validation library (joi, yup, superstruct..etc) and after that, I need to cast the date object to iso string I use Flatpikr , react-hook-form , joi OR yup This my approach at first…
Ahmed Ahmed Sayed
  • 195
  • 1
  • 4
  • 12
0
votes
1 answer

Yup, how to validate one variable against a function of several other ones?

I'm trying to implement a yup validation schema and lets say I have five numeric values (A, B, C, D, E) I want D and E be less than a math function based on A,B,C and some constant value. Something like this: const upperBound =…
AleX_
  • 508
  • 1
  • 6
  • 20
0
votes
1 answer

How to submit ant design form with formik

Hello developer friends. I'm trying to submit my form but i will not succeed. what's wrong with my code? I'm using ant design ui library with formik package and Yup schema validation. Schema validation: const schema = Yup.object().shape({ title:…
ShaSha
  • 589
  • 3
  • 9
  • 24
0
votes
2 answers

How in vuejs3 app with vee-validate/yup to show custom error message?

If there is a way in vuejs3 app with vee-validate and yup to show custom error message? I make select input input with placeholder:
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
0
votes
1 answer

How can i use NextJS routes with a form in React

this is my app component const App = () => { const classes = useStyles(); const formik = useFormik({ initialValues: { name: "", email: "", password: "", confirmPassword: "" }, validationSchema: Yup.object({ …
Alvaro
  • 43
  • 1
  • 9
0
votes
2 answers

Reactjs and Yup, problem with react-hook-form integration

I'm working with yup and react-hook-forms to validate a user submission. I'm creating an application that sends text messages, emails, and push notifications. The user can specify where they would like to be contacted via a set of checkboxes. These…
TheFunk
  • 981
  • 11
  • 39