- Added pnpm-workspace.yaml to define package structure. - Created prepare-local-env.py script for local environment setup. - Introduced tsconfig.json for TypeScript configuration. - Added turbo.json for task management with Turbo.
17 lines
528 B
TypeScript
17 lines
528 B
TypeScript
import { ValueObject } from "@repo/rdx-ddd";
|
|
import { Result } from "@repo/rdx-utils";
|
|
|
|
export class PhoneNumber extends ValueObject<string> {
|
|
static create(value: string): Result<PhoneNumber, Error> {
|
|
const normalized = value.trim();
|
|
if (
|
|
normalized.length > 50 ||
|
|
!/^\+?[0-9 ().-]{3,50}(?: ?(?:x|ext\.?) ?[0-9]{1,8})?$/.test(normalized) ||
|
|
!/[0-9]/.test(normalized)
|
|
) {
|
|
return Result.fail(new Error("Teléfono inválido."));
|
|
}
|
|
return Result.ok(new PhoneNumber(normalized));
|
|
}
|
|
}
|