Refinement functions are now called with valid, but potentially unrefined values. Previously the functions passed in to refine would always be called with sub-elements (eg. when using objects or arrays) that were completely valid and refined. However, this prevented collecting all the refinement errors from subelements in a validation in one go, which is common when validating forms. Note: this should not have any affect on almost all use cases, so you're safe to upgrade.
0.15.0 — March 25, 2021
FIXED
Unions can now be coerced. Previously unions created a barrier in coercion such that structs nested inside unions would not have their coercion logic triggered, but this has been fixed.
Assigning preserves type structs. Previously using the assign helper would implicitly convert type structs into object structs which wasn't expected and confusing, but this has been fixed.
0.14.0 — January 26, 2021
BREAKING
The mask helper now works for nested objects. Previously it would only mask the properties at the top-level of a struct, however now it acts deeply. You can use it to define object structs once, but use them either strictly or loosely.
The masked coercion has been removed. This previously allowed you to mix in masking to a specific struct, but the mask helper is a more robust way to do this, and it doesn't force you to maintain two separate structs.
0.13.0 — December 11, 2020
NEW
Structs can now define an entries iterator for nested values. Previously iterating through nested values was defined in a one-off manner inside certain structs, but this led to non-uniform support. Now, any struct can define an entries iterator that will cause nested values to be automatically coerced and validated.
Coercion receives context objects and supports nested values. Previously context objects were only passed to the validations and refinements. But now the same context is passed to coercions too so you can implement more complex logic. And coercions are automatically applied to nested values thanks to the addition of entries.
Iteration logic has gotten simpler, and more performant. The addition of the entries logic has enabled us to only ever iterate through a tree of values one time for coercion and validation, instead of once each. This should speed up most standard use cases.
BREAKING
The ctx.fail() function has been removed. Previously you'd use it to return more information about a failure inside a struct. Now you can simply return a partial failure object.
The ctx.check() function has been removed. Previously you'd use it to validate nested objects in more complex struct shapes. Now you can use the new entries property for this instead.
The context.struct and context.value properties have been removed. These properties were previously available, but unnecessary since anywhere you have the context object you will also know the value and the specific struct that is being validated. Keeping them around required extra unnecessary plumbing in the library that made composing structs much more difficult so they were removed.
0.12.0 — November 24, 2020
NEW
New Describe utility type. This new utility lets you define a struct from an existing TypeScript type and ensure that the struct's validation matches it, otherwise TypeScript's compiler will error. For example:
type User = {
id: number
name: string
</tr></table>
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps superstruct from 0.15.5 to 0.16.0.
Changelog
Sourced from superstruct's changelog.
... (truncated)
Commits
09f8580
v0.16.0a9fd7ba
update changelogd1508a9
Run refiners as long as validators passed (#1068)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)