Configurable bip39 validation (#2574)
This commit is contained in:
parent
a3657740a8
commit
b4298ca866
@ -19,7 +19,7 @@ export default {
|
||||
'```litcli sessions add --type custom --label <your label> --account_id <account_id> --uri /lnrpc.Lightning/SendPaymentSync```',
|
||||
'Grab the `pairing_secret_mnemonic` from the output and paste it here.'
|
||||
],
|
||||
validate: bip39Validator(),
|
||||
validate: bip39Validator({ min: 2, max: 10 }),
|
||||
required: true,
|
||||
encrypt: true,
|
||||
editable: false
|
||||
|
@ -142,7 +142,7 @@ export const invoiceMacaroonValidator = () =>
|
||||
message: 'not an invoice macaroon or an invoicable macaroon'
|
||||
})
|
||||
|
||||
export const bip39Validator = () =>
|
||||
export const bip39Validator = ({ min = 12, max = 24 } = {}) =>
|
||||
string()
|
||||
.test({
|
||||
name: 'bip39',
|
||||
@ -155,11 +155,11 @@ export const bip39Validator = () =>
|
||||
return context.createError({ message: `'${w}' is not a valid pairing phrase word` })
|
||||
}
|
||||
}
|
||||
if (words.length < 2) {
|
||||
return context.createError({ message: 'needs at least two words' })
|
||||
if (words.length < min) {
|
||||
return context.createError({ message: `needs at least ${min} words` })
|
||||
}
|
||||
if (words.length > 10) {
|
||||
return context.createError({ message: 'max 10 words' })
|
||||
if (words.length > max) {
|
||||
return context.createError({ message: `max ${max} words` })
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user