Compare commits
2 Commits
98a0231906
...
d55dee448b
| Author | SHA1 | Date | |
|---|---|---|---|
| d55dee448b | |||
| 4c891fb8c8 |
@ -1,9 +1,9 @@
|
||||
import { Result } from "@repo/rdx-utils";
|
||||
import {
|
||||
DomainValidationError,
|
||||
ValidationErrorDetail,
|
||||
isDomainValidationError,
|
||||
isValidationErrorCollection,
|
||||
ValidationErrorDetail,
|
||||
} from "../errors";
|
||||
|
||||
/**
|
||||
@ -43,7 +43,7 @@ export function extractOrPushError<T>(
|
||||
error.details?.forEach((detail) => {
|
||||
errors.push({
|
||||
...detail,
|
||||
path: detail.path ?? path,
|
||||
path: path ?? detail.path,
|
||||
});
|
||||
});
|
||||
} else if (isDomainValidationError(error)) {
|
||||
|
||||
@ -9,8 +9,8 @@ export function translateZodValidationError<T>(
|
||||
const errors: ValidationErrorDetail[] = [];
|
||||
for (const issue of zodError.issues) {
|
||||
errors.push({
|
||||
message: issue.message,
|
||||
path: issue.path.join("."),
|
||||
message: `${message}: ${issue.message}`,
|
||||
path: issue.path ? issue.path.join(".") : undefined,
|
||||
value: errorValue ?? issue.input,
|
||||
});
|
||||
}
|
||||
|
||||
@ -42,6 +42,19 @@ export class UtcDate extends ValueObject<UtcDateProps> {
|
||||
return Result.ok(new UtcDate({ value: isoDateString }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creador estático: devuelve la fecha de HOY en UTC a medianoche (00:00:00Z).
|
||||
* - Evita ambigüedades de zona horaria construyendo el ISO explícitamente.
|
||||
*/
|
||||
static today(): UtcDate {
|
||||
const now = new Date();
|
||||
const y = now.getUTCFullYear();
|
||||
const m = String(now.getUTCMonth() + 1).padStart(2, "0");
|
||||
const d = String(now.getUTCDate()).padStart(2, "0");
|
||||
const iso = `${y}-${m}-${d}T00:00:00Z`;
|
||||
return new UtcDate({ value: iso });
|
||||
}
|
||||
|
||||
getProps(): string {
|
||||
return this.props.value;
|
||||
}
|
||||
@ -57,7 +70,7 @@ export class UtcDate extends ValueObject<UtcDateProps> {
|
||||
* Devuelve la fecha en formato UTC sin hora (YYYY-MM-DD).
|
||||
*/
|
||||
toDateString(): string {
|
||||
return this.date.toISOString().split("T")[0];
|
||||
return this.date.toISOString().split("T")[0] ?? "";
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user