Skip to content

isRequiredIf fork of prop-types. #12

@joshuapinter

Description

@joshuapinter

@evcohen You did a great job with this! It's too bad that prop-types is in maintenance mode now and won't merge this in.

The company I work for went ahead and created a fork that adds isRequiredIf functionality. It takes a function and gets passed the props, like:

id: PropTypes.number.isRequiredIf( props => !props.uid )

It doesn't take a boolean like yours does because we didn't require that.

Anyway, just wanted to say thanks for your efforts and if anybody is still stuck using prop-types and wants to use a natural syntax for conditional requirements, feel free to use it. It can be found here:

https://github.com/cntral/prop-types/tree/isRequiredIf

And you can easily use it in your package.json like so:

"prop-types": "github:cntral/prop-types#isRequiredIf"

🍻

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