需要帮助比较从表单提交agaisnt生成的对象先前提交的对象
因此,我正在构建一个数据收集软件,该软件在很大程度上依赖表单和表单验证。我目前已经使用formik和yup建立了动态表单,并通过个人验证进行了验证,但是我希望深入研究用户当前输入agaisnt先前的输入,以确保基于表单的对象的相同键的值逐渐增加或减少设置。
const ObjOne =
{
NumberOne: 100,
NumberTwo: 200,
NumberThree: 300,
}
const ObjTwo =
{
NumberOne: 150,
NumberTwo: 250,
NumberThree: 350,
}
我想设置某种系统来比较这两个对象,以验证用户当前提交numberOne
在对象两个
中的提交是否适当地比对象一个。如果所述值不增加,则将返回错误,告诉用户数据无效。
如果有人可以帮助我集思广益,以实现这一目标或将我指向正确的方向,我将非常感谢它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例中,您可以执行一个基本函数,该功能比较
numberOne
值:在此示例中,仅比较numberOne值,但您可以执行更复杂的功能来检查所有键。此示例只需回答您的特定问题。
这为给定的示例提供了工作:
With your example, you can do a basic function which compare
NumberOne
values: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: