import BigNumber from 'bignumber.js'
export const IsMnemonic = (validationOptions?: ValidationOptions) =>
function (object: Object, propertyName: string) {
registerDecorator({
name: 'isMnemonic',
target: object.constructor,
propertyName: propertyName,
options: {
message: 'Mnemonic must contains between 12 and 24 words. Remove white spaces at end and start from your mnemonic.',
...validationOptions,
},
validator: {
validate(value: any) {
const bigNumberValue = new BigNumber(value.split(' ').length)
return bigNumberValue.lte(24) && bigNumberValue.gte(12)
},
},
})
}
Description
I would like to add mnemonic validation
Proposed solution