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) {
|
if (field.validate.test) {
|
||||||
validator = validator.test({
|
validator = validator.test({
|
||||||
name: field.name,
|
name: field.name,
|
||||||
test: field.validate.test,
|
...(typeof field.validate.test === 'function' ? { test: field.validate.test } : field.validate.test)
|
||||||
message: field.validate.message
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,10 @@ export const fields = [
|
||||||
autoComplete: 'off',
|
autoComplete: 'off',
|
||||||
validate: {
|
validate: {
|
||||||
type: 'email',
|
type: 'email',
|
||||||
test: addr => !addr.endsWith('@stacker.news'),
|
test: {
|
||||||
message: 'automated withdrawals must be external'
|
test: addr => !addr.endsWith('@stacker.news'),
|
||||||
|
message: 'automated withdrawals must be external'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -27,8 +27,10 @@ export const fields = [
|
||||||
clear: true,
|
clear: true,
|
||||||
validate: {
|
validate: {
|
||||||
type: 'hexOrBase64',
|
type: 'hexOrBase64',
|
||||||
test: v => isInvoiceMacaroon(v) || isInvoicableMacaroon(v),
|
test: {
|
||||||
message: 'not an invoice macaroon or an invoicable macaroon'
|
test: v => isInvoiceMacaroon(v) || isInvoicableMacaroon(v),
|
||||||
|
message: 'not an invoice macaroon or an invoicable macaroon'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue