Update schemas boolean, byteSize, and duration to coerce strings#54177
Update schemas boolean, byteSize, and duration to coerce strings#54177jportner merged 10 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/kibana-security (Team:Security) |
|
Renamed this PR to reflect the expanded scope. Regarding The |
pgayvallet
left a comment
There was a problem hiding this comment.
LGTM for platform changes
Some nits and comments:
| expect(() => schema.boolean().validate([1, 2, 3])).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate('abc')).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate(0)).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate('no')).toThrowErrorMatchingSnapshot(); |
There was a problem hiding this comment.
Note to self: error messages are short, should replace with inline snapshots in the whole types tests to increase tests readability. (out of the scope of the PR)
There was a problem hiding this comment.
Yeah, when we wrote this library we didn't use inline snapshots in Kibana yet (or it wasn't supported by that version of Jest, can't recall already).
|
ACK: Reviewing... |
azasypkin
left a comment
There was a problem hiding this comment.
LGTM, thanks! Just a couple of test related nits and note about updating Readme file.
| expect(() => schema.boolean().validate([1, 2, 3])).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate('abc')).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate(0)).toThrowErrorMatchingSnapshot(); | ||
|
|
||
| expect(() => schema.boolean().validate('no')).toThrowErrorMatchingSnapshot(); |
There was a problem hiding this comment.
Yeah, when we wrote this library we didn't use inline snapshots in Kibana yet (or it wasn't supported by that version of Jest, can't recall already).
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…stic#54177) * Update Duration to coerce number strings to numbers (in millis) * Coerce in a way that's consistent with kbn-config-schema * Update ByteSizeValue to coerce strings to numbers * Update Boolean to coerce strings to boolean values * Fix Jest test * Address PR review feedback * Whoops * Whoops 2 * Whoops 3
) (#54299) * Update Duration to coerce number strings to numbers (in millis) * Coerce in a way that's consistent with kbn-config-schema * Update ByteSizeValue to coerce strings to numbers * Update Boolean to coerce strings to boolean values * Fix Jest test * Address PR review feedback * Whoops * Whoops 2 * Whoops 3
* master: (23 commits) [Vis: Default editor] Reactify the timelion editor (elastic#52990) [Discover] fix histogram min interval (elastic#53979) [Telemetry] [Monitoring] Only retry fetching usage once monito… (elastic#54309) [docs][APM] Add runtime index config documentation (elastic#53907) [SIEM] Detection engine timeline (elastic#53783) Filter scripted fields preview field list to source fields (elastic#53826) Management - New platform api (elastic#52579) Reset region and Account when switching inventory (elastic#54287) [SIEM] [Case] Case workflow api schema (elastic#51535) Code coverage setup on CI (elastic#49003) [ML] DF Analytics Results: adds link to docs (elastic#54189) Update schemas boolean, byteSize, and duration to coerce strings (elastic#54177) [Metrics UI] Pass relevant shouldAllowEdit capabilities into SettingsPage (elastic#49781) [Canvas] Fixes bugs with autoplay and refresh (elastic#53149) [ML] DF Analytics Classification: ensure confusion matrix can be fetched (elastic#53629) Fix Vega react eslint errors (elastic#54259) Remove non existing codeowners (elastic#54274) use correct type (elastic#54244) [Dashboard] Removing 100% as dshDashboardViewport height (elastic#54263) add `examples/` to no-restricted-path config (elastic#54252) ...
Summary
This PR updates the
boolean,byteSize, anddurationschemas in the Kibana Platform to coerce string values.boolean: now accepts'true'and'false'(case-insensitive).byteSize: now accepts number strings; assumes any string that doesn't have a unit ('b', 'kb', 'mb', etc.) must be bytes.duration: now accepts number strings; assumes any string that doesn't have a time format ('ms', 'h', 'd', etc.) must be milliseconds.Fixes: #54172