1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

Validate time only fields

This commit is contained in:
Adria Navarro 2024-05-23 11:33:41 +02:00
parent 4a9c1ada0f
commit f6146c4974

View file

@ -205,6 +205,10 @@ export async function validate({
} catch (err) {
errors[fieldName] = [`Contains invalid JSON`]
}
} else if (type === FieldType.DATETIME && column.timeOnly) {
if (row[fieldName] && !row[fieldName].match(/^(\d+)(:[0-5]\d){1,2}$/)) {
errors[fieldName] = [`${fieldName} is not a valid time`]
}
} else {
res = validateJs.single(row[fieldName], constraints)
}