<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class DeniedEmail implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        // 금지 이메일 포함 여부
        $deniedEmails = config('denied_email_list') ?? "";
        $deniedEmails = aTrim($deniedEmails);
        $deniedEmails = explode(',', $deniedEmails);

        return (in_array($value, $deniedEmails) ? false : true);
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return "입력하신 E-mail 주소는 사용이 금지되었습니다.";
    }
}
