Skip to content

Commit

Permalink
update index name regex
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Mar 20, 2024
1 parent 40dd60f commit de8aec0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions common/constants/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ACCELERATION_TIME_INTERVAL = [
];

export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)';
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z][a-z_]*$/;
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z0-9_]+$/;
export const ACCELERATION_S3_URL_REGEX = /^(s3|s3a):\/\/[a-zA-Z0-9.\-]+/;
export const SPARK_HIVE_TABLE_REGEX = /Provider:\s*hive/;
export const TIMESTAMP_DATATYPE = 'timestamp';
Expand All @@ -60,7 +60,7 @@ export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices
- 'Materialized View' indices also enable users to define their index name, but they do not have a suffix.
- An example of a 'Materialized View' index name might look like: \`flint_mydatasource_mydb_mytable_myindexname\`.
##### Note:
- All user given index names must be in lowercase letters. Index name cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
- All user given index names must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
`;

export const SKIPPING_INDEX_ACCELERATION_METHODS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ Array [
class="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>
Expand Down Expand Up @@ -2528,7 +2528,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('validateRefreshInterval', () => {

describe('validateIndexName', () => {
it('should return an array with an error message when the index name is invalid', () => {
expect(validateIndexName('_invalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('Iinvalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('-invalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('InVal1d')).toEqual(['Enter a valid index name']);
expect(validateIndexName('invalid_with spaces')).toEqual(['Enter a valid index name']);
Expand All @@ -147,9 +147,13 @@ describe('validateIndexName', () => {

it('should use the ACCELERATION_INDEX_NAME_REGEX pattern to validate the index name', () => {
expect(ACCELERATION_INDEX_NAME_REGEX.test('valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('23valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('___1__')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('23')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid name')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('-invalid')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_invalid')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_invalid')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid.')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid<')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid*')).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const validateWatermarkDelay = (
};

export const validateIndexName = (value: string) => {
// Check if the value does not begin with underscores or hyphens and all characters are lower case
// Check if the value contains lower case letters, numbers and underscore
return !ACCELERATION_INDEX_NAME_REGEX.test(value) ? ['Enter a valid index name'] : [];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down Expand Up @@ -200,7 +200,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down Expand Up @@ -298,7 +298,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ exports[`Advanced Index settings acceleration components renders acceleration in
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const DefineIndexOptions = ({
<>
<EuiFormRow
label="Index name"
helpText='Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.'
helpText='Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.'
isInvalid={hasError(accelerationFormData.formErrors, 'indexNameError')}
error={accelerationFormData.formErrors.indexNameError}
labelAppend={
Expand Down

0 comments on commit de8aec0

Please sign in to comment.