import { Result } from "@repo/rdx-utils"; import * as z from "zod/v4"; import { ValueObject } from "./value-object"; interface URLAddressProps { value: string; } export class URLAddress extends ValueObject { static create(value: string): Result { const valueIsValid = URLAddress.validate(value); if (!valueIsValid.success) { return Result.fail(new Error(valueIsValid.error.issues[0].message)); } return Result.ok(new URLAddress({ value: valueIsValid.data })); } private static validate(value: string) { const schema = z.url({ message: "Invalid URL format" }); return schema.safeParse(value); } getProps(): string { return this.props.value; } toPrimitive() { return this.getProps(); } }