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 isDefined parallel to isRequired #158

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@kheyse-oqton
Copy link

kheyse-oqton commented Jan 31, 2018

Adds the ability to do the following:

PropTypes.string.isDefined // allows null but not undefined

Based on #90 but removes

PropTypes.string.isNotNull // allows undefined but not null
@facebook-github-bot

This comment has been minimized.

Copy link

facebook-github-bot commented Jan 31, 2018

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

return null;
if (props[propName] === null) {
return allowNull ? null : new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
} else if (props[propName] == null) {

This comment has been minimized.

@ljharb

ljharb Feb 8, 2019

Collaborator

might as well only check for undefined here, since we already checked for null above?

Suggested change Beta
} else if (props[propName] == null) {
} else if (typeof props[propName] === 'undefined') {

@ljharb ljharb added the Semver: minor label Feb 8, 2019

@ljharb

This comment has been minimized.

Copy link
Collaborator

ljharb commented Feb 8, 2019

@kheyse-oqton please sign the CLA when you get a chance.

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