This function compares the value from "Value 1" (value1) and "Value 2"(value2) and if they are the same the result is true, else the result is false. The result (true or false) is triggerd with onFieldValueChange (it updates every time one of the valuefields changes). If you want the result to be triggered when clicking the next-button, use onNextStep instead. If the values have to be equal to allow navigation use onBeforeNextStep.
formsApi.onFieldValueChange('value1', compareHandler.bind(formsApi));
formsApi.onFieldValueChange('value2', compareHandler.bind(formsApi));
function compareHandler(value){
let valueOne = formsApi.getFieldValue('value1');
let valueTwo = formsApi.getFieldValue('value2')
result = valueOne === valueTwo
formsApi.setFieldValue('result', result)
}