Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Remove passhrase white space warning and them to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yasharAyari committed Oct 9, 2017
1 parent 3d17420 commit 1727b3e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/components/passphraseInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ class PassphraseInput extends React.Component {

handleValueChange(value) {
let error;
let warning;

if (!value) {
error = 'Required';
} else if (!isValidPassphrase(value)) {
error = this.getPassphraseValidationError(value);
} else if (this.hasExtraWhitespace(value)) {
const warningMessage = this.getPasshraseWhitespaceWarning(value);
warning = warningMessage ? `Warning: ${warningMessage}` : null;
error = this.getPassphraseWhitespaceError(value);
}

this.setState({ warning });
this.props.onChange(value, error);
}

Expand Down Expand Up @@ -61,7 +58,7 @@ class PassphraseInput extends React.Component {
}

// eslint-disable-next-line class-methods-use-this
getPasshraseWhitespaceWarning(passphrase) {
getPassphraseWhitespaceError(passphrase) {
if (passphrase.replace(/^\s+/, '') !== passphrase) {
return 'Passphrase contains unnecessary whitespace at the beginning';
} else if (passphrase.replace(/\s+$/, '') !== passphrase) {
Expand All @@ -82,7 +79,7 @@ class PassphraseInput extends React.Component {
<div className={styles.wrapper}>
<Input label={this.props.label} required={true}
className={this.props.className}
error={this.props.error || this.state.warning}
error={this.props.error}
value={this.props.value || ''}
type={this.state.inputType}
theme={this.props.theme}
Expand Down

0 comments on commit 1727b3e

Please sign in to comment.