-
Notifications
You must be signed in to change notification settings - Fork 847
Closed
Labels
flag: needs discussionIssues which needs discussion before implementation.Issues which needs discussion before implementation.type: featureIssues related to new features.Issues related to new features.
Description
Description
I would like to add mnemonic validation
Proposed solution
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)
},
},
})
}
Metadata
Metadata
Assignees
Labels
flag: needs discussionIssues which needs discussion before implementation.Issues which needs discussion before implementation.type: featureIssues related to new features.Issues related to new features.