Fix date validation regex
This commit is contained in:
parent
cb115f4f11
commit
7147752b9c
|
@ -657,4 +657,16 @@ describe("SQL query builder", () => {
|
|||
sql: `select * from (select top (@p0) * from [test] order by [test].[id] asc) as [test]`,
|
||||
})
|
||||
})
|
||||
|
||||
it("should not parse JSON string as Date", () => {
|
||||
let query = new Sql(SqlClient.POSTGRES, limit)._query(
|
||||
generateCreateJson(TABLE_NAME, {
|
||||
name: '{ "created_at":"2023-09-09T03:21:06.024Z" }',
|
||||
})
|
||||
)
|
||||
expect(query).toEqual({
|
||||
bindings: ['{ "created_at":"2023-09-09T03:21:06.024Z" }'],
|
||||
sql: `insert into \"test\" (\"name\") values ($1) returning *`,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -182,7 +182,7 @@ export function getSqlQuery(query: SqlQuery | string): SqlQuery {
|
|||
export const isSQL = helpers.isSQL
|
||||
|
||||
export function isIsoDateString(str: string) {
|
||||
if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(str.trim())) {
|
||||
return false
|
||||
}
|
||||
let d = new Date(str)
|
||||
|
|
Loading…
Reference in New Issue