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

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
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new validator request Requests for a new kind of validator.
Projects
None yet
Development

No branches or pull requests

2 participants