Xpressengine\User\UserHandler::validateForCreate PHP Method

validateForCreate() public method

신규회원의 정보를 유효성 검사한다.
public validateForCreate ( array $data ) : boolean
$data array 회원의 정보
return boolean 유효성검사 결과, 통과할 경우 true, 실패할 경우 false
    public function validateForCreate(array $data)
    {
        // 필수 요소 검사
        if (!isset($data['status'], $data['rating'], $data['displayName'])) {
            throw new InvalidArgumentException();
        }
        // email이나 account중 하나는 반드시 있어야 한다.
        if (!isset($data['email']) && !isset($data['account'])) {
            $e = new InvalidArgumentException();
            $e->setMessage('email이나 account중 하나가 반드시 있어야 합니다.');
            throw $e;
        }
        // email, displayName 중복검사
        if (isset($data['email'])) {
            if ($this->emails()->findByAddress($data['email']) !== null) {
                throw new MailAlreadyExistsException();
            }
        }
        // displayName 검사
        $this->validateDisplayName($data['displayName']);
        // account 검사
        if (isset($data['account'])) {
            $account = $data['account'];
            if (!isset($account['accountId'], $account['provider'], $account['data'], $account['token'])) {
                $e = new InvalidArgumentException();
                $e->setMessage('account 정보가 올바르지 않습니다.');
                throw $e;
            }
            if ($this->accounts()->where(array_only($account, ['accountId', 'provider']))->first() !== null) {
                throw new AccountAlreadyExistsException();
            }
        }
        return true;
    }