Comments (5)
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.
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.
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.
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.
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)
- It only works for the current request HOT 4
- Bad method call HOT 1
- Validation fails when updating composite keys with ignore HOT 1
- Using that validation rule with renamed fileds
- Update for Laravel 6.0 HOT 1
- Can't seem to get it working for Polymorph fields HOT 2
- How to add deleted_at, NULL HOT 2
- Update for Laravel 8.0 HOT 10
- Please add support for PHP 8 HOT 1
- Ignore is not working in array validation HOT 1
- unique_with can't validation on multiple column
- Migrate test suite from Travis to Github Actions HOT 1
- Wrong locale set on app
- Compatibility Issue with laravel 9 php 8.X HOT 11
- Counter-intuitive deleted_at in rules
- Ignoring deleted items not working properly
- Laravel 5.4 : doesn't work on updating ! HOT 5
- its not working with database connection HOT 1
- Giving duplicate entry in every new entry HOT 2
- Is there a possibility of a validator plugin for exist_with? HOT 2
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 uniquewith-validator.