kibana/x-pack/plugins/transform/public/app/common/aggregations.ts
James Gowdy 55e4c7f9a7
[ML] Consolidating shared types and util functions (#65247)
* [ML] Consolidating shared types and util functions

* including formatter

* adding missing includes

* removing unused export

* ignoring numeral type error

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-05-07 12:23:42 +01:00

19 lines
669 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { composeValidators, patternValidator } from '../../../../ml/public';
export type AggName = string;
export function isAggName(arg: any): arg is AggName {
// allow all characters except `[]>` and must not start or end with a space.
const validatorFn = composeValidators(
patternValidator(/^[^\s]/),
patternValidator(/[^\s]$/),
patternValidator(/^[^\[\]>]+$/)
);
return validatorFn(arg) === null;
}