-
Notifications
You must be signed in to change notification settings - Fork 158
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 string checks for IPv4, IPv6 #353
Conversation
What should I do about the MiMa errors about 2.11 and 2.10? |
@NeQuissimus In principle these predicates would be a welcome addition but I'm afraid we can't use val x: String Refined IPv4 = "github.com" would perform a DNS lookup at compile-time and therefore compilation would be dependent on the network. This should be avoided. As far as I can see |
@fthomas Oooh, I did not know about |
Out of curiosity, is there an easy way to implement these predicates without adding additional dependencies? |
Well, you could create Regex' to match them but then you'll end up with giant regular expressions :) All the JDK stuff makes DNS calls as far as I know. |
Actually, we could boolean a very simple regex on top of this PR to avoid DNS lookups... |
I can look into published refined-guava. That was based on some work I did that also needed IP address parsing, but I didn't want to side-effect. Unfortunately, guava is a big dependency for that. @fthomas Would you want this as a module for refined, or would you prefer it as a separate project? |
@fthomas @derekmorr Or, we could use apache/commons-validator, which is much smaller, and would allow us to add a bunch of stuff. (think credit card numbers, email address...) |
I don't have any experience with commons-validator but if it is more suitable than Guava, go for it. However, one downside of Java dependencies is that we won't be able to cross-compile it for Scala.js and Scala Native. |
Uses
java.net.Inet{,4,6}Address
to determine whether a String is a valid IPv4/IPv6.