Skip to content

Commit

Permalink
improve tsdoc on validation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Apr 8, 2021
1 parent 5239a44 commit cb0327c
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ interface ValidationContext {
}

/**
* Validates an aggregation structure against the declared mapping and
* aggregation schema, and rewrite the attribute fields from the
* `{type}.attributes.{attribute}` (KQL-like) syntax to the underlying
* `{type}.{attribute} format.`
* Validate an aggregation structure against the declared mappings and
* aggregation schemas, and rewrite the attribute fields using the KQL-like syntax
* - `{type}.attributes.{attribute}` to `{type}.{attribute}`
* - `{type}.{rootField}` to `{rootField}`
*
* throws on the first validation error if any is encountered.
*/
export const validateAndConvertAggregations = (
allowedTypes: string[],
Expand All @@ -46,12 +48,9 @@ export const validateAndConvertAggregations = (
};

/**
* Validates a record of aggregation containers,
* Validate a record of aggregation containers,
* Which can either be the root level aggregations (`SearchRequest.body.aggs`)
* Or a nested record of aggregation (`SearchRequest.body.aggs.myAggregation.aggs`)
*
* @param aggregations
* @param context
*/
const validateAggregations = (
aggregations: Record<string, estypes.AggregationContainer>,
Expand All @@ -66,11 +65,8 @@ const validateAggregations = (
};

/**
* Validates an aggregation container, e.g an entry of `SearchRequest.body.aggs`, or
* from a nested aggregation record.
*
* @param aggregation
* @param context
* Validate an aggregation container, e.g an entry of `SearchRequest.body.aggs`, or
* from a nested aggregation record, including its potential nested aggregations.
*/
const validateAggregation = (
aggregation: estypes.AggregationContainer,
Expand All @@ -91,6 +87,10 @@ const validateAggregation = (
return container;
};

/**
* Validates root-level aggregation of given aggregation container
* (ignoring its nested aggregations)
*/
const validateAggregationContainer = (
container: estypes.AggregationContainer,
context: ValidationContext
Expand Down

0 comments on commit cb0327c

Please sign in to comment.