MCPcopy Create free account
hub / github.com/Forward-Future/loopy / validateDate

Function validateDate

loop-library/worker/src/loop-schema.js:211–221  ·  view source on GitHub ↗
(value, field)

Source from the content-addressed store, hash-verified

209}
210
211function 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
223function isPlainObject(value) {
224 return value !== null && typeof value === "object" && !Array.isArray(value);

Callers 1

normalizeLoopDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected