Validate time only fields

This commit is contained in:
Adria Navarro 2024-05-23 11:33:41 +02:00
parent 4a9c1ada0f
commit f6146c4974
1 changed files with 4 additions and 0 deletions

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)
}