/** Values sent to Django are integer bytes (null = no per-space limit). */ const GIB = 1024 ** 3 export const fromQuota = bytes => bytes == null ? '' : String(Number((bytes / GIB).toFixed(3))) export function toQuota(value) { if (value === '') return null const trimmed = String(value).trim().replace(',', '.') if (!/^\d+(\.\d{1,3})?$/.test(trimmed)) throw new Error('Entre un quota positif en Go, avec 3 décimales maximum.') const bytes = Math.round(Number(trimmed) * GIB) if (!Number.isSafeInteger(bytes)) throw new Error('Ce quota est trop élevé.') return bytes }