Closed furyozo closed 1 year ago
Ad.:
Moving the Illuminate\Validation\Rules\Unique
into the array in place of the custom UserPhoneUniqueRule
as such:
PhoneNumber::make(static::transField('phone'), 'phone')
->onlyCountries(PhoneNumberValidity::PHONE_NUMBER_COUNTRIES)
->rules([
$phoneNumberValidity->phoneNumber()->nullable()->toArray(),
(new Unique($usersTable, 'phone'))->ignoreModel($this->resource)
]),
also seems to work correctly.
The issue was in the phone number formatting logic on our side
First off, thank you so much for implementing this package, it helped me and my team a lot. :)
Way to replicate the issue:
Display a nested resource inside Nova creation form using
Laravel\Nova\Fields\HasOne
relationship. In the nested resource fields() method define a PhoneNumber as follows:The unique constraint validation rule will not get applied when submitting the form.
After replacing the PhoneNumber field with a
Laravel\Nova\Fields\Text
field, the unique constraint validation gets applied succesfully.For now I have circumvented this feature by using a custom rule as such:
But I would still love to be able to use the default rules() method in a way consistent with the
Laravel\Nova\Fields\Field
public function rules($rules)
method.