Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to validate a single value? #9

Closed
Neophen opened this issue Mar 24, 2020 · 2 comments
Closed

How to validate a single value? #9

Neophen opened this issue Mar 24, 2020 · 2 comments

Comments

@Neophen
Copy link

Neophen commented Mar 24, 2020

In this case:

{
  "en":"unique_title", //scoped for en
  "lt":"unique_title", //scoped for lt
}
<input name="title_en" value="unique_title" />
<input name="title_lt" value="some other title"/>

I want to have different validation for each input like:

$attributes = request()->validate([
    'title_lt' => 'required|unique_translation:posts:title',
    'title_en' => 'unique_translation:posts:title',
]);

how would i check against a specific value? Or this will just work?

@ivanvermeyen
Copy link
Contributor

Hello,

This should work:

{
  "en":"unique_title", //scoped for en
  "lt":"unique_title", //scoped for lt
}
<input name="title[en]" value="unique_title" />
<input name="title[lt]" value="some other title"/>
$attributes = request()->validate([
    'title.lt' => 'required|unique_translation:posts:title',
    'title.en' => 'unique_translation:posts:title',
]);

@Neophen
Copy link
Author

Neophen commented Mar 24, 2020

yup all works fine! amazing package thank you!

@Neophen Neophen closed this as completed Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants