Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda