Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Add a PropType for an exact shape plus "...rest" properties  #405

Description

@effulgentsia

Suppose I want something like this:

PropTypes.exact({
  x: PropTypes.boolean,
  y: PropTypes.string.isRequired,
  "...rest": PropTypes.objectOf(PropTypes.string)
})

The above won't work because I don't want to apply that last validator to a property named ...rest, I want to apply it to the rest object that you would get when you destructure the remaining properties.

Is this possible to do with existing prop types, or would it require a new prop type, such as:

PropTypes.exactPlusRest({
  x: PropTypes.boolean,
  y: PropTypes.string.isRequired
}, PropTypes.string)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions