[Security Solution][Detection Rules] Fixes Threshold rule schema validator (#87946)
This commit is contained in:
parent
752a2bd943
commit
25bac19321
|
@ -13,7 +13,7 @@ import {
|
||||||
singleEntryThreat,
|
singleEntryThreat,
|
||||||
containsInvalidItems,
|
containsInvalidItems,
|
||||||
} from '../../../../common/components/threat_match/helpers';
|
} from '../../../../common/components/threat_match/helpers';
|
||||||
import { isThreatMatchRule } from '../../../../../common/detection_engine/utils';
|
import { isThreatMatchRule, isThresholdRule } from '../../../../../common/detection_engine/utils';
|
||||||
import { isMlRule } from '../../../../../common/machine_learning/helpers';
|
import { isMlRule } from '../../../../../common/machine_learning/helpers';
|
||||||
import { esKuery } from '../../../../../../../../src/plugins/data/public';
|
import { esKuery } from '../../../../../../../../src/plugins/data/public';
|
||||||
import { FieldValueQueryBar } from '../query_bar';
|
import { FieldValueQueryBar } from '../query_bar';
|
||||||
|
@ -216,16 +216,25 @@ export const schema: FormSchema<DefineStepRule> = {
|
||||||
),
|
),
|
||||||
validations: [
|
validations: [
|
||||||
{
|
{
|
||||||
validator: fieldValidators.numberGreaterThanField({
|
validator: (
|
||||||
than: 1,
|
...args: Parameters<ValidationFunc>
|
||||||
message: i18n.translate(
|
): ReturnType<ValidationFunc<{}, ERROR_CODE>> | undefined => {
|
||||||
'xpack.securitySolution.detectionEngine.validations.thresholdValueFieldData.numberGreaterThanOrEqualOneErrorMessage',
|
const [{ formData }] = args;
|
||||||
{
|
const needsValidation = isThresholdRule(formData.ruleType);
|
||||||
defaultMessage: 'Value must be greater than or equal to one.',
|
if (!needsValidation) {
|
||||||
}
|
return;
|
||||||
),
|
}
|
||||||
allowEquality: true,
|
return fieldValidators.numberGreaterThanField({
|
||||||
}),
|
than: 1,
|
||||||
|
message: i18n.translate(
|
||||||
|
'xpack.securitySolution.detectionEngine.validations.thresholdValueFieldData.numberGreaterThanOrEqualOneErrorMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: 'Value must be greater than or equal to one.',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
allowEquality: true,
|
||||||
|
})(...args);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue