statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Allow overwriting the column used by `unique_user_value` validator #1067

Closed marcorieser closed 8 months ago

marcorieser commented 8 months ago

I tried to tuck away the fields needed for my registration process with the new Livewire Form Objects.

namespace App\Livewire;

use Livewire\Component;
use App\Livewire\Forms\RegistrationForm;

class Registration extends Component
{
    public RegistrationForm $form;

    ...
}

Due to that nesting, the field handles used for validation get prefixed with form. (e.g. form.email) and therefore checking for existing users with unique_user_value always passes since there is no user with form.email set.

// App/Livewire/Forms/RegistrationForm.php

#[Rule("required|email|unique_user_value")]
public string $email;

It would be great if there was a way to pass along the column (e.g. email) to be validated on.