Files
buzz-sheet/lib/guides/percent-input.ts
T
gunshiz 51e74eee04
CI / Verify (push) Successful in 1m1s
CI / Build immutable images and deploy (push) Successful in 2m4s
fix(admin) : clarify validation and normalize percent input
2026-09-02 21:21:03 +07:00

11 lines
324 B
TypeScript

const DECIMAL = /^-?(?:\d+\.?\d*|\.\d*)?$/u;
export function normalizePercentInput(nextValue: string, currentValue = ""): string {
const value = nextValue.trim();
return DECIMAL.test(value) ? value : currentValue;
}
export function finalizePercentInput(value: string): string {
return value === "-" ? "0" : value;
}