Skip to content

Commit

Permalink
Add CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Apr 6, 2019
1 parent 255e729 commit d7453da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export class AutoFollowPatternForm extends PureComponent {
this.setState(({ fieldsErrors }) => updateFormErrors(errors, fieldsErrors));
} else {
this.setState(({ fieldsErrors, autoFollowPattern: { leaderIndexPatterns } }) => {
// If have at least 1 auto-follow pattern in our state, we validate its value
// otherwise, we validate the *current value* of the form input
const errors = Boolean(leaderIndexPatterns.length)
// Validate existing patterns, so we can surface an error if this required input is missing.
? validateAutoFollowPattern({ leaderIndexPatterns })
// Validate the input as the user types so they have immediate feedback about errors.
: validateAutoFollowPattern({ leaderIndexPatterns: [leaderIndexPattern] });

return updateFormErrors(errors, fieldsErrors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const validateLeaderIndexPattern = (indexPattern) => {
};

export const validateLeaderIndexPatterns = (indexPatterns) => {
// We only need to check if a value has been provided, because validation for this field
// has already been executed as the user has entered input into it.
if (!indexPatterns.length) {
return {
message: i18n.translate('xpack.crossClusterReplication.autoFollowPattern.leaderIndexPatternValidation.isEmpty', {
Expand All @@ -100,13 +102,7 @@ export const validateLeaderIndexPatterns = (indexPatterns) => {
};
}

let error = null;
indexPatterns.forEach((indexPattern) => {
if (!error) {
error = validateLeaderIndexPattern(indexPattern);
}
});
return error;
return null;
};

export const validatePrefix = (prefix) => {
Expand Down

0 comments on commit d7453da

Please sign in to comment.