Skip to content
Advertisement

Laravel unique validation on multiple columns

I have 2 columns in table servers.

I have columns ip and hostname.

I have validation:

JavaScript

This working only for column ip. But how to do that it would work and for column hostname?

I want validate data.ip with columns ip and hostname. Because can be duplicates in columns ip and hostname, when user write ip.

Advertisement

Answer

You can use Rule::unique to achieve your validation rule

JavaScript

edit: Fixed message assignation

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement