(value, field)
| 209 | } |
| 210 | |
| 211 | function validateDate(value, field) { |
| 212 | if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) { |
| 213 | throw new LoopValidationError(`${field} must use YYYY-MM-DD.`); |
| 214 | } |
| 215 | |
| 216 | const parsed = new Date(`${value}T00:00:00Z`); |
| 217 | |
| 218 | if (Number.isNaN(parsed.valueOf()) || parsed.toISOString().slice(0, 10) !== value) { |
| 219 | throw new LoopValidationError(`${field} must be a real calendar date.`); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | function isPlainObject(value) { |
| 224 | return value !== null && typeof value === "object" && !Array.isArray(value); |
no outgoing calls
no test coverage detected