Comments (20)
I like the constructor param, but don't like being the second. I believe this is possible:
v::ip(FILTER_FLAG_IPv4); //using a filter_input flag as it already does
v::ip('192.168.0.*'); //using the new range validation
We can distinguish them by the type. Filter flags are always integer and our range pattern is always string =) What do you guys think?
from validation.
+1
from validation.
This v::ip('192.168.0.*')
looks interesting. +1.
from validation.
@drgomesp your're right =)
from validation.
@alganet and I talked a little bit on facebook about this trying to find the best way to code.
We said about using the Between rule - without the ip2long() - internally (just like Between and Domain does), but after some tests I found out that we really need to use that function:
var_dump('192.168.2.2' <= '192.168.2.255'); //true
var_dump('192.168.0.2' > '192.168.0.0'); //true
var_dump('192.168.2.6' >= '192.168.0.0' && '192.168.2.6' <= '192.168.2.255'); //false
var_dump(ip2long('192.168.2.2') <= ip2long('192.168.2.255')); //true
var_dump(ip2long('192.168.0.2') > ip2long('192.168.0.0')); //true
var_dump(ip2long('192.168.2.6') >= ip2long('192.168.0.0') && ip2long('192.168.2.6') <= ip2long('192.168.2.255')); //true
I'm implementing this right now and I'll send a PR soon ;)
from validation.
So, I think travis is broken, someone knows about it?
from validation.
We saw that, but something odd is happening. All tests passed before I commit =/
@alganet will remove the --testdox param on phpunit execution so we can see what's going on.
from validation.
Don't worry @lcobucci! Unfortunately is not the first time that PHPUnit trolling us.
from validation.
Any idea? https://travis-ci.org/Respect/Validation/jobs/4088431
//CC @augustohp, @alganet, @wesleyvicthor, @nickl-
from validation.
That helps.
The validation that I've coded will do the following things.
- Calculate the min address by replacing * to 0
- Calculate the max address by replacing * to 255
- Assert that the long value of the address is between the long value of min and max addresses.
That lead us to this code:
var_dump(ip2long('10.168.2.6')); // int(178782726)
var_dump(ip2long('0.168.2.6')); // int(11010566)
var_dump(ip2long('255.168.2.6')); // int(4289200646)
var_dump(
ip2long('10.168.2.6') >= ip2long('0.168.2.6')
&& ip2long('10.168.2.6') <= ip2long('255.168.2.6')
); // bool(true)
As I mentioned before the test suite is 100% here...
from validation.
I know man, really! Take a look:
- OSX: 100%;
- Fedora 17: "Segmentation fault (core dumped)" at test
Respect\Validation\ValidatorTest::test_set_template_with_multiple_validators_should_use_template_as_full_message
; - Travis: Failure on "Respect\Validation\Rules\IpTest::test_ips_between_range_should_return_True with data set #5 ('10.168.2.6', '*.168.2.6')".
from validation.
Is this related, in any way, to #87?
from validation.
I think so, but PHPunit, XDebug and PHP don't decide of who is this bug, it is like a ping-pong game.
from validation.
Sad but true.
Sebastian Bergmann thinks this could be related to the zend distribution of PHP.
from validation.
I believe it's the integer size. We'll need to check for PHP_INT_MAX and use the bccomp function if the integer size sucks 32bits. 64bit should be fine though. Wonder what could have happend with IPv6 addresses =/
from validation.
@drgomesp The funny thing is this occurs with some frequency when running PHPUnit tests..
from validation.
Fixed on #105
from validation.
Waiting for Travis... today it's of screw <~ Brazilian joke detected.
from validation.
Bad translation detected.
from validation.
Stops-goods! You got it!
from validation.
Related Issues (20)
- ctype_digit deprecation notice HOT 1
- Release 2.2.4 HOT 2
- Roadmap to 2.3 HOT 13
- Code coverage in local environment HOT 2
- [documentaiton] Validation for a full array of data HOT 3
- Formatter inconsequently stringifies values HOT 6
- IBAN Validation with non-breaking spaces HOT 1
- How do custom validation rules throw custom error messages? HOT 2
- How to compare two field HOT 1
- DateTime validation fails on valid ISO-8601 timestamp HOT 1
- phone() validation incorrectly invalidates valid UK phone numbers HOT 2
- phone() in 2.3 dont work correctly HOT 13
- RFC 3339 Z suffix no longer works with date-time validation in 2.3 HOT 16
- Date-related rules are not working today HOT 3
- Unexpected behavior with the country code rule in 2.3 HOT 4
- Roadmap to 3.0
- Increase code coverage HOT 3
- Email validation with accented characters HOT 3
- Why is it mandatory to require the PHP version to be so new? HOT 2
- DateDiff rule HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validation.