Open jonathan-buttner opened 1 year ago
Pinging @elastic/response-ops (Team:ResponseOps)
cc @mikecote
Thank you for the feedback, @jonathan-buttner!
Agreed the validation stories for connector / rule params is not great.
But it turns out the validation is not tied to kbn-config-schema
, we just happened to pick that as our validator when we built alerting, and we adopted their validation signature as our "contract". So, you should be able to provide an object with a validate(thing-you-are-validating) => validated-thing or throw error
as the "schema".
I believe both SIEM and o11y use io-ts etc for validation, for rules, and I'd hope whatever they did there will work for connectors as well. I'm not sure we've used that for any connectors though.
As a longer-term story here, I think the rules-as-code effort (for example, using Terraform to manage rules) is going to impact these things, as we likely won't be able to depend on kbn-config-schema for validation, at least completely. Seems like work-around suggested by me ^^^ will hold us until then.
The actions framework provides validation support through a
validate
function when defining theConnectorTypeModel
. I think the validation functionality could benefit from a few improvements:kbn-schema
which uses Joi, which may not be supported by all browsers and importing it would add ~500KB of data to page loadskbn-schema
kbn-schema
, it'd be helpful to let developers use any validation libraryvalidateParams
function is execute aftereditActions
updates theactionParams
passed to component props. It would be helpful to provide validation functions which could be executed prior to theactionParams
being updated.editActions
because invalid fields could cause the form part to crash if the fields were not the right types