-
Notifications
You must be signed in to change notification settings - Fork 21
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
function to check type #95
Comments
@loomis forgot to ask: do you this is feasible? |
Yes, it is feasible. Probably fairly straightforward to implement. |
to follow the internal code, and not cause any confustion, we settled on the function name ( |
The problem with validate() is discovery -- how does someone know a particular function exists? If the only reason not to use is_type() is because someone might try to apply it to a variable then surely that is best handled in the documentation? |
@ned21 |
Yep, I think I am confused as to what this does. Can you provide a real code example instead of a generic one? Then I might understand it better. :( |
i see 2 main use cases:
type type_ip = string with validate(type_ipv4, SELF) || validate(type_ipv6, SELF); this would get rid of a bunch of functions that are only used because you currently cannot easily combine types (without refactoring or factroing out the validation code).
type configured_nic = string with exists("/system/network/interfaces/" + SELF); and then you can do things like "/software/component/magic/ignore" = {
foreach(nic;data;value("/harwdare/cards/nic")) {
if(! validate(configured_nic, nic)) {
append(nic);
};
};
}; and yes, you can define test functions that only return true/false for this and make more |
The examples in the docs for the PR help explain this better. I can see why Validate remains a vague and overly general term which is very close to the existing |
@ned21 the pan book has the following wrt bind "If any of the content does not conform to the specified types, then an error will occur during the compilation.". maybe @iliclaey feel free to make even more suggestions |
+1 for accuracy of |
What about |
I think |
currently we have a bunch of code that does things like
this is typically used to make new types out of sub-types like
it would make a lot of sense to be able to test the type directly like
The text was updated successfully, but these errors were encountered: