Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
Need help comparing an object generated from a form submission agaisnt a previous submission

So I am building a data collection software that relies heavily on forms and form validations. I have currently built up dynamic forms with Formik and Yup with individual validation but im looking to dive deeper into validating the users current input agaisnt a previous input to make sure the value of the same key from the objects are incrementing or decrementing based on the form settings.

const ObjOne = 
{
   NumberOne: 100,
   NumberTwo: 200,
   NumberThree: 300,
}
const ObjTwo = 
{
   NumberOne: 150,
   NumberTwo: 250,
   NumberThree: 350,
}

I want to setup some sort of system to compare these two objects to validate that the users current submission for NumberOne in Object Two is properly incrementing higher than the previous value in Object One. If said value is not incrementing then it would return an error telling the user the data is not valid.

If someone could help me brainstorm on how to acheive this or point me in the proper direction i would greatly appreciate it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With your example, you can do a basic function which compare NumberOne values:

const ObjOne = 
{
   NumberOne: 100,
   NumberTwo: 200,
   NumberThree: 300,
}
const ObjTwo = 
{
   NumberOne: 150,
   NumberTwo: 250,
   NumberThree: 350,
}

const check = (one, two) => {
if (two.NumberOne > one.NumberOne)
    console.log('ok');
else
    console.log('ko');
}

check(ObjOne, ObjTwo);

In this example, only NumberOne values are compared but you can do a more complicated function to check all keys. This example just answer to your specific question.

This does the job for the given example:

const check = (one, two) => {
if (two.NumberOne < one.NumberOne || two.NumberTwo < one.NumberTwo || two.NumberThree < one.NumberThree)
    console.log('ko');
else
    console.log('ok');
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!