-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ResponseOps][Stack Connectors] Adding custom validators to sub actions framework #142376
[ResponseOps][Stack Connectors] Adding custom validators to sub actions framework #142376
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
} | ||
|
||
interface Validate<T> { | ||
validate: ValidateFn<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe change it to validator
validate: ValidateFn<T>; | ||
} | ||
|
||
export type ValidateFn<T> = (obj: T, services: ValidatorServices) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use ValidatorType['customValidator']<T>
that is defined x-pack/plugins/actions/server/types.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah great point.
@@ -42,3 +52,40 @@ export const buildValidators = < | |||
}, | |||
}; | |||
}; | |||
|
|||
const buildCustomValidators = <Config, Secrets>( | |||
validators?: Array<ConfigValidator<Config> | SecretsValidator<Secrets>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can create a type in x-pack/plugins/actions/server/sub_action_framework/types.ts
and use it here.
const buildCustomValidators = <Config, Secrets>( | ||
validators?: Array<ConfigValidator<Config> | SecretsValidator<Secrets>> | ||
) => { | ||
const partitionedValidators = validators?.reduce<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: To improve readability this can be turned to a normal for-of-loop.
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
History
To update your PR or re-run it, just comment with: |
…ns framework (elastic#142376) * Adding custom validators * Updating README and tests * Fixing translation error * Addressing feedback Co-authored-by: Kibana Machine <[email protected]>
…ns framework (elastic#142376) * Adding custom validators * Updating README and tests * Fixing translation error * Addressing feedback Co-authored-by: Kibana Machine <[email protected]>
The actions framework supports custom validators. A common one is to ensure the url used for an external integration is specified within the Kibana allowed URLs. This PR adds the custom validators logic to the sub actions framework and adds a common url validator for use by consumers.