Skip to content

Commit

Permalink
[Watcher UI] Not possible to edit a watch that was created with the A…
Browse files Browse the repository at this point in the history
…PI if the ID contains a dot (#59383) (#60297)

* Add . period to the isRegex variable L34

* Undo ID2 back to ID , done for testing

* Updated the Jest test message to include period

* Undo exception message to include periods

* Removed duplicate comments
  • Loading branch information
jkelastic committed Mar 16, 2020
1 parent 541a9cf commit 83a5b78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../es_ui_shared/console_lang/mocks';

import { act } from 'react-dom/test-utils';
Expand Down Expand Up @@ -76,7 +77,7 @@ describe('<JsonWatchEdit /> create route', () => {
actions.clickSubmitButton();

expect(form.getErrorsMessages()).toContain(
'ID can only contain letters, underscores, dashes, and numbers.'
'ID can only contain letters, underscores, dashes, periods and numbers.'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class JsonWatch extends BaseWatch {

validate() {
const validationResult = {};
const idRegex = /^[A-Za-z0-9\-\_]+$/;
const idRegex = /^[A-Za-z0-9\-\_.]+$/;
const errors = {
id: [],
json: [],
Expand All @@ -47,7 +47,7 @@ export class JsonWatch extends BaseWatch {
} else if (!idRegex.test(this.id)) {
errors.id.push(
i18n.translate('xpack.watcher.sections.watchEdit.json.error.invalidIdText', {
defaultMessage: 'ID can only contain letters, underscores, dashes, and numbers.',
defaultMessage: 'ID can only contain letters, underscores, dashes, periods and numbers.',
})
);
}
Expand Down

0 comments on commit 83a5b78

Please sign in to comment.