-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detections][Threshold Rules][7.12] Final Threshol…
…d Rule Fixes for 7.12 (#93553) * refactor * Add explicit to/from * cleanup * A bit more cleanup * Fix threshold signal history bug when rule is edited * Added comments * more cleanup, fix tests * Add tests later * Reverse the tuples array * Fix getThresholdBucketFilters test * Fix translations
- Loading branch information
Showing
25 changed files
with
821 additions
and
710 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/plugins/es_ui_shared/static/forms/helpers/field_validators/max_length.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { ValidationFunc, ValidationError } from '../../hook_form_lib'; | ||
import { hasMaxLengthString } from '../../../validators/string'; | ||
import { hasMaxLengthArray } from '../../../validators/array'; | ||
import { ERROR_CODE } from './types'; | ||
|
||
export const maxLengthField = ({ | ||
length = 0, | ||
message, | ||
}: { | ||
length: number; | ||
message: string | ((err: Partial<ValidationError>) => string); | ||
}) => (...args: Parameters<ValidationFunc>): ReturnType<ValidationFunc<any, ERROR_CODE>> => { | ||
const [{ value }] = args; | ||
|
||
// Validate for Arrays | ||
if (Array.isArray(value)) { | ||
return hasMaxLengthArray(length)(value) | ||
? undefined | ||
: { | ||
code: 'ERR_MAX_LENGTH', | ||
length, | ||
message: typeof message === 'function' ? message({ length }) : message, | ||
}; | ||
} | ||
|
||
// Validate for Strings | ||
return hasMaxLengthString(length)((value as string).trim()) | ||
? undefined | ||
: { | ||
code: 'ERR_MAX_LENGTH', | ||
length, | ||
message: typeof message === 'function' ? message({ length }) : message, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.