Skip to content

[7.x] [NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema (#51919)#53714

Merged
afharo merged 1 commit intoelastic:7.xfrom
afharo:backport/7.x/pr-51919
Dec 21, 2019
Merged

[7.x] [NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema (#51919)#53714
afharo merged 1 commit intoelastic:7.xfrom
afharo:backport/7.x/pr-51919

Conversation

@afharo
Copy link
Copy Markdown
Member

@afharo afharo commented Dec 20, 2019

Backports the following commits to 7.x:

…chema (elastic#51919)

* [NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema

* API docs

* Allow validate function in the route handler (run-code validation)

* Prefix RouteXXX + Params and Body Validation Aliases

* Fix test broken by lodash

* Update API docs

* Add default types for simpler manual declaration

* Add run-time validation of the RouteValidateSpec

* Expose RouteValidationError instead of SchemaTypeError

* RouteValidator as a class to match config-schema interface

* Test for not-inline handler (need to check IRouter for elastic#47047)

* Add preValidation of the input for a safer custom validation

* Better types for RouteHandlers

* [NP] Move route validation to RouteValidator wrapper

* Use the class only internally but maintain the same API

* Fix types

* Ensure RouteValidator instance in KibanaRequest.from

* Fix validator.tests (Buffer.from instead of new Buffer)

* Default precheck should allow null values

* Also allow undefined in preChecks

* MR feedback fixes

* Provide RouteValidationResolver to the validation function

* Add functional tests

* Fix new functional tests

* Fix validator additional test

* Fix test with new resolver

* Remove unused import

* Rename ValidationResolver to ValidationResultFactory and change the interface to look more like the KibanaResponseFactory

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@afharo afharo added the backport This PR is a backport of another PR label Dec 20, 2019
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@afharo afharo merged commit f3f1bd2 into elastic:7.x Dec 21, 2019
@afharo afharo deleted the backport/7.x/pr-51919 branch January 28, 2020 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants