<?php

namespace Lucent\Account;

use JsonSerializable;
use Lucent\Validator\Validator;


class Email implements JsonSerializable
{
    private string $value;
    function __construct(string $value)
    {
        Validator::single("Email", $value, "required|email|min:6|max:50");
        $this->value = \strtolower($value);
    }

    function value(): string
    {
        return $this->value;
    }

    function __toString(): string{
        return $this->value;
    }

    public function jsonSerialize(): string
    {
        return $this->value;
    }
}
