🚸 (number) Avoid parsing numbers starting with 0
This commit is contained in:
@ -1082,6 +1082,14 @@
|
||||
"First name": "John",
|
||||
"Email": "john@gmail.com"
|
||||
}
|
||||
},
|
||||
"textBubbleContentFormat": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"richText",
|
||||
"markdown"
|
||||
],
|
||||
"default": "richText"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1441,6 +1449,14 @@
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"textBubbleContentFormat": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"richText",
|
||||
"markdown"
|
||||
],
|
||||
"default": "richText"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1855,6 +1871,14 @@
|
||||
"sessionId": {
|
||||
"type": "string",
|
||||
"description": "If provided, will be used as the session ID and will overwrite any existing session with the same ID."
|
||||
},
|
||||
"textBubbleContentFormat": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"richText",
|
||||
"markdown"
|
||||
],
|
||||
"default": "richText"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11879,19 +11903,41 @@
|
||||
]
|
||||
},
|
||||
"content": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"html": {
|
||||
"type": "string"
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"richText"
|
||||
]
|
||||
},
|
||||
"richText": {
|
||||
"type": "array",
|
||||
"items": {}
|
||||
"richText": {}
|
||||
},
|
||||
"plainText": {
|
||||
"required": [
|
||||
"type"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"markdown"
|
||||
]
|
||||
},
|
||||
"markdown": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type",
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
@ -1 +1,4 @@
|
||||
export const parseNumber = (value: string) => Number(value).toString()
|
||||
export const parseNumber = (value: string) => {
|
||||
if (value.startsWith('0')) return value
|
||||
return parseFloat(value).toString()
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ export const validateNumber = (
|
||||
variables: Variable[]
|
||||
}
|
||||
) => {
|
||||
if (inputValue === '') return false
|
||||
|
||||
const parsedNumber = Number(inputValue)
|
||||
if (isNaN(parsedNumber)) return false
|
||||
|
||||
const min =
|
||||
options?.min && typeof options.min === 'string'
|
||||
? Number(parseVariables(variables)(options.min))
|
||||
@ -20,10 +25,8 @@ export const validateNumber = (
|
||||
options?.min && typeof options.min === 'string'
|
||||
? Number(parseVariables(variables)(options.min))
|
||||
: undefined
|
||||
|
||||
return (
|
||||
inputValue !== '' &&
|
||||
(isNotDefined(min) || Number(inputValue) >= min) &&
|
||||
(isNotDefined(max) || Number(inputValue) <= max)
|
||||
(isNotDefined(min) || parsedNumber >= min) &&
|
||||
(isNotDefined(max) || parsedNumber <= max)
|
||||
)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ./.env -e ../../.env -- tsx scripts/studio.ts",
|
||||
"db:generate": "dotenv -e ./.env -e ../../.env -- tsx scripts/db-generate.ts",
|
||||
"db:generate:mysql": "DATABASE_URL=mysql:// dotenv -e ./.env -e ../../.env -- tsx scripts/db-generate.ts",
|
||||
"db:push": "dotenv -e ./.env -e ../../.env -- tsx scripts/db-push.ts",
|
||||
"migrate:deploy": "dotenv -e ./.env -e ../../.env -- tsx scripts/migrate-deploy.ts",
|
||||
"migrate:dev": "dotenv -e ./.env -e ../../.env -- prisma migrate dev --create-only --schema postgresql/schema.prisma",
|
||||
|
Reference in New Issue
Block a user