import { UndefinedOr } from "../../../../utilities";
import { IValueObjectOptions, ValueObject } from "./ValueObject";

export interface IStringValueObjectOptions extends IValueObjectOptions {}

export class StringValueObject extends ValueObject<UndefinedOr<string>> {
  public isEmpty = (): boolean => {
    return this.toString().length === 0;
  };

  public toString = (): string => {
    return this.props ? String(this.props) : "";
  };

  public toPrimitive(): string {
    return this.toString();
  }

  get value(): UndefinedOr<string> {
    return !this.isEmpty() ? this.props : undefined;
  }
}
