-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Suggestion:Validation on defined types #8665
Comments
Looks like the same thing as #6579. i would add implementation suggestions in that issue instead of creating a new one. |
Sorry, I thought that should be in a different issue because the other was just about allow regex patterns in types and I'm asking for a more general feature, but I will suggest there. Thank you! |
@mhegazy Is this a duplicate of #6579? The first and third examples could be covered by #6579 but the middle example is not regex based. Furthermore, for the first example, the integer check could (and probably should) be implemented without a regex:
|
Please see #4639 |
@mhegazy If I understand you correctly, the OP provides three examples: Are there no other possible type validations possible with this?
|
@mhegazy Considering that the OP's comment on #6579 has (as of this writing) garnered 67 +1s, and this proposal is broader than any of the other more limited special case proposals, can this be reopened? |
These are called Dependent Types: https://en.wikipedia.org/wiki/Dependent_type A very powerful feature indeed, especially if done generically as opposed to case-by-case (regex, range types, etc). If pursued in this form, we would need to be wary of what is or is not allowed in such type predicates (e.g. no type system within the type predicate), since this could lead to undecidable type checking... |
It would be nice if we could write some kind of validation on user defined types. Something like:
The value that the type can accept would be determined by the function parameter type and by the function evaluation itself. That would solve other issues like #6902, #6579 or #7982
The text was updated successfully, but these errors were encountered: