Make clear that message belongs to test
* validate.message was used in tandem with validate.test * it might be confused as the message if the validation for validate.type failed * now validate.test can be a function or an object of { test, message } shape which matches Yup.test
This commit is contained in:
parent
c8d91bf42d
commit
6a5713034b
|
@ -90,8 +90,7 @@ export function generateSchema (wallet) {
|
|||
if (field.validate.test) {
|
||||
validator = validator.test({
|
||||
name: field.name,
|
||||
test: field.validate.test,
|
||||
message: field.validate.message
|
||||
...(typeof field.validate.test === 'function' ? { test: field.validate.test } : field.validate.test)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ export const fields = [
|
|||
autoComplete: 'off',
|
||||
validate: {
|
||||
type: 'email',
|
||||
test: addr => !addr.endsWith('@stacker.news'),
|
||||
message: 'automated withdrawals must be external'
|
||||
test: {
|
||||
test: addr => !addr.endsWith('@stacker.news'),
|
||||
message: 'automated withdrawals must be external'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -27,8 +27,10 @@ export const fields = [
|
|||
clear: true,
|
||||
validate: {
|
||||
type: 'hexOrBase64',
|
||||
test: v => isInvoiceMacaroon(v) || isInvoicableMacaroon(v),
|
||||
message: 'not an invoice macaroon or an invoicable macaroon'
|
||||
test: {
|
||||
test: v => isInvoiceMacaroon(v) || isInvoicableMacaroon(v),
|
||||
message: 'not an invoice macaroon or an invoicable macaroon'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue