16 lines
421 B
TypeScript
16 lines
421 B
TypeScript
import { Result } from "@repo/rdx-utils";
|
|
|
|
import { ValueObject } from "./value-object.vo";
|
|
|
|
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));
|
|
}
|
|
}
|