<?php

namespace Lucent\Account;

use JsonSerializable;
use Lucent\LucentException;
use Lucent\Validator\Validator;


class Name implements JsonSerializable
{
    public string $value;

    /**
     * @throws LucentException
     */
    function __construct(string $value)
    {
        Validator::single("Name", $value, "required|min:2|max:50");
        $this->value = $value;
    }

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

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

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