Giter Club home page Giter Club logo

Comments (20)

alganet avatar alganet commented on August 22, 2024

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.

wesleyvicthor avatar wesleyvicthor commented on August 22, 2024

+1

from validation.

drgomesp avatar drgomesp commented on August 22, 2024

This v::ip('192.168.0.*') looks interesting. +1.

from validation.

alganet avatar alganet commented on August 22, 2024

@drgomesp your're right =)

from validation.

lcobucci avatar lcobucci commented on August 22, 2024

@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.

henriquemoody avatar henriquemoody commented on August 22, 2024

So, I think travis is broken, someone knows about it?

from validation.

lcobucci avatar lcobucci commented on August 22, 2024

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.

henriquemoody avatar henriquemoody commented on August 22, 2024

Don't worry @lcobucci! Unfortunately is not the first time that PHPUnit trolling us. :trollface:

from validation.

henriquemoody avatar henriquemoody commented on August 22, 2024

Any idea? https://travis-ci.org/Respect/Validation/jobs/4088431

//CC @augustohp, @alganet, @wesleyvicthor, @nickl-

from validation.

lcobucci avatar lcobucci commented on August 22, 2024

That helps.
The validation that I've coded will do the following things.

  1. Calculate the min address by replacing * to 0
  2. Calculate the max address by replacing * to 255
  3. 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.

henriquemoody avatar henriquemoody commented on August 22, 2024

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.

drgomesp avatar drgomesp commented on August 22, 2024

Is this related, in any way, to #87?

from validation.

henriquemoody avatar henriquemoody commented on August 22, 2024

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.

drgomesp avatar drgomesp commented on August 22, 2024

Sad but true.

Sebastian Bergmann thinks this could be related to the zend distribution of PHP.

from validation.

alganet avatar alganet commented on August 22, 2024

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.

henriquemoody avatar henriquemoody commented on August 22, 2024

@drgomesp The funny thing is this occurs with some frequency when running PHPUnit tests..

from validation.

lcobucci avatar lcobucci commented on August 22, 2024

Fixed on #105

from validation.

henriquemoody avatar henriquemoody commented on August 22, 2024

Waiting for Travis... today it's of screw <~ Brazilian joke detected. :trollface:

from validation.

drgomesp avatar drgomesp commented on August 22, 2024

Bad translation detected.

troll

from validation.

henriquemoody avatar henriquemoody commented on August 22, 2024

Stops-goods! You got it!

from validation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.