Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature Request: Add depth Option to partial for Nested Optional Attributes #1266

Copy link
Copy link
@yeoffrey

Description

@yeoffrey
Issue body actions

Description

It would be beneficial to enhance the partial function in the superstruct library to support a depth option. This option would allow attributes to be made optional up to a specified level of nested objects.

Example

import { number, object, optional, partial, string } from 'superstruct'

const MyStruct = object({
  name: string(),
  address: object({
    street: string(),
    number: number(),
  }),
})

const PartialMyStruct = partial(MyStruct, { depth: 1 })

// The same as:
// const PartialMyStruct = optional(
//   object({
//     name: optional(string()),
//     address: optional(
//       object({
//         street: string(),
//         number: number(),
//       })
//     ),
//   })
// )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.