omniscientjs / immstruct

Immutable data structures with history for top-to-bottom properties in component based libraries like React. Based on Immutable.js
374 stars 21 forks source link

value validation types #71

Open dashed opened 9 years ago

dashed commented 9 years ago

Something like this for immstruct structures https://github.com/tgriesser/state-types-react https://facebook.github.io/react/docs/reusable-components.html#prop-validation

API sketch:

const blueprint = {
    foo: immstruct.types.string.isRequired
};

immstruct({
    foo: 'bar'
}, blueprint);
dashed commented 9 years ago

Any validation violations would be warnings in the console.

unindented commented 9 years ago

@Dashed Would this fit your use case? https://github.com/HurricaneJames/react-immutable-proptypes

dashed commented 9 years ago

@unindented Cool! I'll definitely check this out.

mikaelbr commented 9 years ago

@Dashed Yeah, the question is. Do we think this is something that Immstruct should do, or is this a React thing?

dashed commented 9 years ago

@mikaelbr I feel this would help debugging a lot.

I didn't really elaborate on my first post; but I wanted to suggest to 'copy' proptype checking that React does and perform the type check against a Structure instance instead of this.props. That way user can use userland proptypes (e.g. HurricaneJames/react-immutable-proptypes) meant for React, and as well as React's proptypes.