-
Notifications
You must be signed in to change notification settings - Fork 220
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
extend core types #79
Comments
@skbolton glad you like it! Could you give a code sample showing what you mean? |
I looked into the source and it would looks like it would be tough to add. But basically a way to add new types in without having to create a new struct out of a superstruct every time.
Doing in this in every file was a little painful. So instead I did it in one file and all of my files using superstruct require that file. Its fine just means I have to manage some crazy require paths sometimes. I was hoping there could be a way to add types to extend the built in ones
So now date verification is available to all superstructs |
Ah @skbolton I see what you mean now. I agree that this would make that case easy, but Superstruct is actually designed purposefully to not allow extend the global behavior like that. Instead, you should do what you're already doing where you instantiate your own I think although the require paths may be slightly frustrating (this can be fixed by having flatter/better code structures), it is very worth the explicitness of having the definitions all live in a single place, and not be globally mutable. |
I totally agree with you. Simple and to the point is how this library can really stand out |
First off awesome library. You have saved me from the muck of json schema!
I find myself having to call superstruct a lot to add date and email validation. I was wondering if it is possible, or could be possible, to extend the core struct instance to have additonal types defined for all structs.
I was doing a special exported struct that I consumed but having to know and manage the require path is getting a tiny bit hairy. Would love your thoughts on this?
The text was updated successfully, but these errors were encountered: