improve validation errors
This commit is contained in:
parent
14b6d7f818
commit
ce3ee703df
|
@ -752,19 +752,19 @@ export const blinkSchema = object().shape({
|
|||
apiKey: string()
|
||||
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' })
|
||||
.when(['apiKeyRecv'], ([apiKeyRecv], schema) => {
|
||||
if (!apiKeyRecv) return schema.required('required if apiKeyRecv not set')
|
||||
if (!apiKeyRecv) return schema.required('required if api key for receiving not set')
|
||||
return schema.test({
|
||||
test: apiKey => apiKey !== apiKeyRecv,
|
||||
message: 'apiKey cannot be the same as apiKeyRecv'
|
||||
message: 'api key for sending cannot be the same as for receiving'
|
||||
})
|
||||
}),
|
||||
apiKeyRecv: string()
|
||||
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' })
|
||||
.when(['apiKey'], ([apiKey], schema) => {
|
||||
if (!apiKey) return schema.required('required if apiKey not set')
|
||||
if (!apiKey) return schema.required('required if api key for sending not set')
|
||||
return schema.test({
|
||||
test: apiKeyRecv => apiKeyRecv !== apiKey,
|
||||
message: 'apiKeyRecv cannot be the same as apiKey'
|
||||
message: 'api key for receiving cannot be the same as for sending'
|
||||
})
|
||||
}),
|
||||
currency: string()
|
||||
|
|
Loading…
Reference in New Issue