14 lines
416 B
TypeScript
14 lines
416 B
TypeScript
|
|
import { Result } from "@repo/rdx-utils";
|
||
|
|
|
||
|
|
import { ValueObject } from "./value-object";
|
||
|
|
|
||
|
|
export class Name extends ValueObject<string> {
|
||
|
|
static create(value: string, maxLength = 255): Result<Name, Error> {
|
||
|
|
const normalized = value.trim();
|
||
|
|
if (!normalized || normalized.length > maxLength) {
|
||
|
|
return Result.fail(new Error("Nombre inválido."));
|
||
|
|
}
|
||
|
|
return Result.ok(new Name(normalized));
|
||
|
|
}
|
||
|
|
}
|