diff --git a/js/src/modals/CreateAccount/RecoveryPhrase/recoveryPhrase.js b/js/src/modals/CreateAccount/RecoveryPhrase/recoveryPhrase.js index 9feaa4d2c..ffa90ef27 100644 --- a/js/src/modals/CreateAccount/RecoveryPhrase/recoveryPhrase.js +++ b/js/src/modals/CreateAccount/RecoveryPhrase/recoveryPhrase.js @@ -54,8 +54,6 @@ export default class RecoveryPhrase extends Component { { - const value = event.target.value; - let error = null; + const recoveryPhrase = event.target.value + .toLowerCase() // wordlists are lowercase + .trim() // remove whitespace at both ends + .replace(/\s/g, ' ') // replace any whitespace with single space + .replace(/ +/g, ' '); // replace multiple spaces with a single space - if (!value || value.trim().length < 25) { - error = ERRORS.noPhrase; + const parts = recoveryPhrase.split(' '); + let recoveryPhraseError = null; + + if (!recoveryPhrase || recoveryPhrase.length < 25 || parts.length < 8) { + recoveryPhraseError = ERRORS.noPhrase; } this.setState({ - recoveryPhrase: value, - recoveryPhraseError: error, - isValidPhrase: !error + recoveryPhrase, + recoveryPhraseError, + isValidPhrase: !recoveryPhraseError }, this.updateParent); }