mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
20 lines
796 B
PHP
20 lines
796 B
PHP
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
|
|
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
|
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
|
|
|
class ValidateRegister
|
|
{
|
|
public function handle(FormBuilder $builder, ProfileRepositoryInterface $profileRepository, $attribute, $value)
|
|
{
|
|
if (!is_numeric($builder->getPostValue('phone'))) {
|
|
$builder->addFormError('phone', trans('visiosoft.module.profile::message.error_valid_phone'));
|
|
return false;
|
|
} elseif (!is_null($profileRepository->findPhoneNumber($builder->getPostValue('phone')))) {
|
|
$builder->addFormError('phone', trans('visiosoft.module.profile::message.registered_phone'));
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|