Giter Club home page Giter Club logo

Comments (6)

axlon avatar axlon commented on May 20, 2024 1

@schonhoff I've merged the changes and tagged it as v3.1.1

from laravel-postal-code-validation.

axlon avatar axlon commented on May 20, 2024

Thank you for the bug report @schonhoff. The correct behaviour for receiving null should be validation failing, bail should not be necessary (except if you want to suppress multiple validation errors on the same input) so this sounds like a bug.

Could you tell me you Laravel and Postal code validation versions?

from laravel-postal-code-validation.

schonhoff avatar schonhoff commented on May 20, 2024

Hello,

no problem. I hope I can help you with this information:

"name": "axlon/laravel-postal-code-validation", "version": "v3.1.0",

"name": "laravel/framework", "version": "v8.6.0",

My current validation rule for my postal code field:

['bail', 'required', 'postal_code:DE']

As you noticed correctly bail shouldn't be necessary, but currently it is for me.
If I return nothing (null) to the validation

$validator = Validator::make($data, $rules, $messages);
if($validator->fails())

throws the error message. With the fixed code on my first post I don't get an error and the validation works like you described.

from laravel-postal-code-validation.

schonhoff avatar schonhoff commented on May 20, 2024

Just a hint:

on your src\Extensions\PostalCode Class you are using
public function validate(string $attribute, ?string $value, array $parameters)
on the validate function but in the function passes you are calling there needs to be a string.

public function passes(string $countryCode, string ...$postalCodes): bool

I guess that this is the error. Maybe it is because of php 7.4 that I'm currently using.

from laravel-postal-code-validation.

axlon avatar axlon commented on May 20, 2024

@schonhoff Could you review the changes I made in PR linked above? I think they should fix your issue. Note that validation will still pass if the given country has no pattern and null is passed

from laravel-postal-code-validation.

schonhoff avatar schonhoff commented on May 20, 2024

@axlon copied the changes to my local system and it seems like it fixes the issue. Thanks for the fast fix!

from laravel-postal-code-validation.

Related Issues (16)

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.