-
Notifications
You must be signed in to change notification settings - Fork 46
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 mapContains prop type #24
Conversation
I don't think this is related to #15 . That issue deals with validating the type and/or format of the keys themselves. That is useful when you don't actually know what they keys will be, but you do know what type/format they need to be. It's already possible without this pr to validate the name of keys in a map and the types of the values of each key. |
@MatthewHerbst I believe you might be thinking of #4 maybe?
I believe this PR is a solution specific to that use case. |
@hartzis oh yes, very sorry - too many issues to keep track of! 🎱 |
What would you think about naming it |
i like |
); | ||
} | ||
var mutablePropValue = propValue.toJS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This morning I realized I should probably convert this back to .toObject
. I hadn't realized before today that it only shallowly converts. Which allows you to continue to propType check deeply for Immutable objects.
Immutable.fromJS({a: [1, 2]}).toObject() => { a: List [ 1, 2 ] }
Immutable.fromJS({a: [1, 2]}).toJS() => { a: [ 1, 2 ] }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.toObject
allows for:
mapContains({
id: PropTypes.string.isRequired,
list: listOf(mapContains({
val: PropTypes.number.isRequired,
})).isRequired,
})
Updated the PR:
|
@HurricaneJames looks like you accidentally wrote let me know if you see anything else with this PR, and I'll get it updated asap. Cheers. |
merged, made a couple changes, and published v1.7.0 to npm. |
attempt to add functionality for #15
Example data:
Example proptypes:
please give feedback. maybe a different name?
mapShapeOf
,mapHasShape
I will update the docs when/if this functionality is agreed upon.