Code Monkey home page Code Monkey logo

Comments (5)

felixkiss avatar felixkiss commented on July 25, 2024

When updating a record with say id 123, you can just add the following to the rule: ,ignore:123 and it will ignore that ID when searching for currently existing foreign keys.

from uniquewith-validator.

yelnyafacee avatar yelnyafacee commented on July 25, 2024

I see, thanks for the reply, I currently have a pivot table with user_id and a res_id and no primary ID key, and this is how my $rules currently look like:

$rules = [

'user_id' => 'required|integer|unique_with:user_visit_count,res_id,ignore:' . $user,
'res_id' => 'required|integer',

......

];

the validation error message is showing:

This combination of user id, res id, ignore:{"id":1, cardnumber id:2, name:" ....... } already exists.

In the UPDATE request, if the user_id and res_id is not changed, but the extra pivot table attributes are changed, then it will show the validation error message like above, any way to ignore the user_id and res_id of current existing row?

seems the unique_with validation requires the id column which the pivot table dont have

from uniquewith-validator.

felixkiss avatar felixkiss commented on July 25, 2024

Only one ignore column is supported, since this library uses Laravel's PresenceVerifierInterface. But you could specify the name like this:

'user_id' => 'required|integer|unique_with:user_visit_count,res_id, ignore:' . $user->id . ' = user_id',

In your case this won't help, but I would suggest adding a auto-incrementing id to the table and using that for the ignore.

from uniquewith-validator.

MicroDreamIT avatar MicroDreamIT commented on July 25, 2024

anyway I am trying to use this for unique name, but its not working. Any help will be appreciated,

'name' => 'required|min:3|unique_with:categories,type,name,ignore:' . $this->name . ' = name',

from uniquewith-validator.

felixkiss avatar felixkiss commented on July 25, 2024

Old issue. Sorry for not responding. I assume you don't need more help. If you need, feel free to reopen.

from uniquewith-validator.

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.