Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Disabled or None type #315

Open
arxeiss opened this issue May 21, 2020 · 1 comment
Open

Add Disabled or None type #315

arxeiss opened this issue May 21, 2020 · 1 comment
Labels
new validator request Requests for a new kind of validator.

Comments

@arxeiss
Copy link

arxeiss commented May 21, 2020

When I create a custom component input and I'm passing all props from the parent, sometimes I want to disable some of them. In the example below I don't want to allow the user to be able to override type.
But it is not possible now. I would like to add something like PT.disabled to warn users, that this prop is prohibited to change.

const NumberInput = (props) => {
  const { type, className, ...rest } = props;

  return <input
    type="number"
    {...rest}
    className={ classnames(inputStyles.number) + ' ' + className }
  />;
};

NumberInput.propTypes = {
  className: PT.string,
  type: PT.disabled, // Here, warn user type is not available property
};

export default NumberInput;

Would it be possible to add something like this?

@ljharb
Copy link
Collaborator

ljharb commented May 21, 2020

https://npmjs.com/airbnb-prop-types has this as restrictedProp.

I don't think it's likely to be worth adding new stuff here; I'd suggest using that library instead.

@ljharb ljharb added the new validator request Requests for a new kind of validator. label May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new validator request Requests for a new kind of validator.
Projects
None yet
Development

No branches or pull requests

2 participants