[Vuejs]-Laravel validation 'sometimes' with 'present' rule isn't overriding the values rules in the validation

0👍

replacing ‘present’ with nullable fixed the issue.

public function rules(): array
{
    return [
        'name' => ['sometimes', 'nullable', 'string', 'max:255'],
        'username' => ['sometimes','nullable', 'max:255', 'string', 'unique:users,username'],
        'email' => ['sometimes', 'nullable', 'email', 'unique:users,email', 'max:255'],
        'password' => ['sometimes', 'nullable','min:8', 'max:255', 'confirmed']
    ];
}

Leave a comment