refactor: error message building
This commit is contained in:
parent
0379da13b7
commit
473aada9e1
1 changed files with 8 additions and 11 deletions
|
|
@ -114,21 +114,18 @@ const Schema = Yup.object()
|
||||||
txVolume: threshold => {
|
txVolume: threshold => {
|
||||||
const thresholdMessage = 'Volume must be greater than or equal to 0'
|
const thresholdMessage = 'Volume must be greater than or equal to 0'
|
||||||
const thresholdDaysMessage = 'Days must be greater than 0'
|
const thresholdDaysMessage = 'Days must be greater than 0'
|
||||||
const message = [thresholdMessage, thresholdDaysMessage]
|
const message = []
|
||||||
if (threshold.threshold < 0 && threshold.thresholdDays <= 0)
|
if (threshold.threshold < 0) message.push(thresholdMessage)
|
||||||
return message.join(', ')
|
if (threshold.thresholdDays <= 0) message.push(thresholdDaysMessage)
|
||||||
if (threshold.threshold < 0) return message[0]
|
return message.join(', ')
|
||||||
if (threshold.thresholdDays <= 0) return message[1]
|
|
||||||
},
|
},
|
||||||
txVelocity: threshold => {
|
txVelocity: threshold => {
|
||||||
const thresholdMessage = 'Transactions must be greater than 0'
|
const thresholdMessage = 'Transactions must be greater than 0'
|
||||||
const thresholdDaysMessage = 'Days must be greater than 0'
|
const thresholdDaysMessage = 'Days must be greater than 0'
|
||||||
const message = [thresholdMessage, thresholdDaysMessage]
|
const message = []
|
||||||
if (threshold.threshold <= 0 && threshold.thresholdDays <= 0)
|
if (threshold.threshold <= 0) message.push(thresholdMessage)
|
||||||
return message.join(', ')
|
if (threshold.thresholdDays <= 0) message.push(thresholdDaysMessage)
|
||||||
if (threshold.threshold <= 0) return message[0]
|
return message.join(', ')
|
||||||
if (threshold.thresholdDays <= 0) return message[1]
|
|
||||||
return message
|
|
||||||
},
|
},
|
||||||
consecutiveDays: threshold => 'Days must be greater than 0'
|
consecutiveDays: threshold => 'Days must be greater than 0'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue