Coder Social home page Coder Social logo

Comments (3)

kirillarutyunov avatar kirillarutyunov commented on June 14, 2024

The same problem with - instead of /.

So I tried to change test case:

public function it_checks_expiration_date()
{
    // ...
    $this->assertTrue($this->dateValidator('02-18', 'MM-YY')->passes());
    // ...
}

And it fails :–(.

This 02-18 value and MM-YY format are from examples in README.md, but this do not work.

from credit-card.

kirillarutyunov avatar kirillarutyunov commented on June 14, 2024

I found the source of my problems: there is incorrect format. The right one is Carbon::createFromFormat('m/y', '06/23'). Need to fix it in README.md and change MM-YY format there.

I can fix readme. But what to do with Carbon::parse() and its exception? What do you think?

from credit-card.

skeemer avatar skeemer commented on June 14, 2024

I just ran into this issue because I wanted to use the 'm/Y' format. The Carbon::parse() doesn't do anything helpful. I ended up having to abandon this validation for regex/date_format/after validations.

I think that line was added because it blocks a string like '3/22' without a leading zero because there is no way to enforce checking for the leading 0 with the date parsing in PHP. The only way I can thing to fix that is by doing a string comparison of the string to be parsed to the result formatted back. Unfortunately, then formats that you want to have match leading 0 not required but allowed wouldn't be reliable.

from credit-card.

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.