Skip to content

Commit 70547de

Browse files
[ML] Align transform id validation with regexp used in ES code. (#98783) (#98895)
Fixes isTransformIdValid() to use the same RegExp used in Elasticsearch's transform code. Co-authored-by: Walter Rafelsberger <walter@elastic.co>
1 parent 0f5204f commit 70547de

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

x-pack/plugins/transform/public/app/common/transform.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import { Subscription } from 'rxjs';
1212

1313
import { TransformId } from '../../../common/types/transform';
1414

15-
// Transform name must contain lowercase alphanumeric (a-z and 0-9), hyphens or underscores;
16-
// It must also start and end with an alphanumeric character.
15+
// Via https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/utils/TransformStrings.java#L24
16+
// Matches a string that contains lowercase characters, digits, hyphens, underscores or dots.
17+
// The string may start and end only in characters or digits.
18+
// Note that '.' is allowed but not documented.
1719
export function isTransformIdValid(transformId: TransformId) {
18-
return /^[a-z0-9\-\_]+$/g.test(transformId) && !/^([_-].*)?(.*[_-])?$/g.test(transformId);
20+
return /^[a-z0-9](?:[a-z0-9_\-\.]*[a-z0-9])?$/g.test(transformId);
1921
}
2022

2123
export enum REFRESH_TRANSFORM_LIST_STATE {

0 commit comments

Comments
 (0)