fix: update car color validation to handle both string and number types

This commit is contained in:
RustamRu 2025-03-12 17:41:48 +03:00
parent 41dbe81001
commit d64ece382a

View File

@ -10,7 +10,14 @@ const { getGigaToken, getSystemPrompt } = require('./get-token')
const isValidPhoneNumber = (value) => /^(\+)?\d{9,15}/.test(value)
const isValidCarNumber = (value) => /^[авекмнорстух][0-9]{3}[авекмнорстух]{2}[0-9]{2,3}$/i.test(value)
const isValidCarBodyType = (value) => typeof value === 'number' && value > 0 && value < 100
const isValidCarColor = (value) => value.length < 50 && /^[#a-z0-9а-я-\s,.()]+$/i.test(value)
const isValidCarColor = (value) => {
if (typeof value === 'number') {
return value >= 0 && value <= 7
} else if (typeof value === 'string') {
return /^[#a-z0-9а-я-\s,.()]+$/i.test(value)
}
return false
}
const isValidISODate = (value) => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:.\d{1,3})?Z$/.test(value)
const latitudeRe = /^(-?[1-8]?\d(?:\.\d{1,18})?|90(?:\.0{1,18})?)$/