I would like to validate a list of items(strings) and make sure there isn't a duplication(if there is, show error message) when user tries to modify the item. However, if the user try to modify it and finally keep the same value, we don't show the error message. In validation, I have something like below for each field in the array. In the function inside test below, I can only get current modified value as parameter - value, but not previous value so I cannot do validation with previous value. I would like to know if there is a way to get previous value(i.e. value before any change) for the value currently been modified? If there is only one value in the list, it is easy, but if there are multiples, it is hard to track.
Yup.object().shape({
rows: Yup.array(
Yup.lazy(() => (
myObject.test('field', 'error message', function (value) { ... } )
)
)
)
})