Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.10] Allow empty field name for supporting timeframe and keywords when validating rule during creation/update #830

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cypress/integration/2_rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,20 @@ describe('Rules', () => {
it('...should validate selection map key field', () => {
getSelectionPanelByIndex(0).within(() => {
getMapKeyField().should('be.empty');
getMapKeyField().focus().blur();
getMapKeyField()
.focus()
.blur()
.parents('.euiFormRow__fieldWrapper')
.find('.euiFormErrorText')
.should('not.exist');

getMapKeyField().type('hello@');
getMapKeyField()
.parentsUntil('.euiFormRow__fieldWrapper')
.siblings()
.contains('Invalid key name');

getMapKeyField().type('FieldKey');
getMapKeyField().focus().type('{selectall}').type('FieldKey');
getMapKeyField()
.focus()
.blur()
Expand Down Expand Up @@ -441,7 +448,6 @@ describe('Rules', () => {
getSelectionPanelByIndex(0).within(() =>
getMapKeyField().type('{selectall}').type('{backspace}')
);
toastShouldExist();
getSelectionPanelByIndex(0).within(() => getMapKeyField().type('FieldKey'));

// selection map value field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ export class DetectionVisualEditor extends React.Component<
if ('field' in data) {
const fieldName = `field_${selIdx}_${idx}`;
delete errors.fields[fieldName];
if (!validateDetectionFieldName(data.field)) {

if (data.field && !validateDetectionFieldName(data.field)) {
errors.fields[fieldName] =
'Invalid key name. Valid characters are a-z, A-Z, 0-9, hyphen, period, and underscore.';
}
Expand Down
Loading