Removed some validations that were unneccesary for expert submit

This commit is contained in:
SepehrYahyaee
2026-09-06 12:09:34 +03:30
parent 233a16d96c
commit c9b5b6f765
5 changed files with 74 additions and 43 deletions

View File

@@ -5,22 +5,18 @@ import {
ValidatorConstraint,
ValidatorConstraintInterface,
} from "class-validator";
import { normalizeMoneyAmountString } from "src/utils/unicode-digits";
import { parseMoneyAmountToman } from "src/utils/unicode-digits";
@ValidatorConstraint({ name: "isMoneyAmountString", async: false })
export class IsMoneyAmountStringConstraint
implements ValidatorConstraintInterface
{
export class IsMoneyAmountStringConstraint implements ValidatorConstraintInterface {
validate(value: unknown): boolean {
if (value == null || value === "") return true;
if (typeof value !== "string") return false;
const n = normalizeMoneyAmountString(value);
if (!n) return false;
return /^\d+(\.\d+)?$/.test(n);
return parseMoneyAmountToman(value) !== null;
}
defaultMessage(): string {
return "Must be a non-negative amount (digits only, optional decimal).";
return "Must be a non-negative whole-Toman amount.";
}
}