Skip to content

Commit

Permalink
Feature: Remove arbitrary maximum integer values. Implements le0pard#101
Browse files Browse the repository at this point in the history
  • Loading branch information
jmealo committed Nov 29, 2024
1 parent b3c16bd commit b9e7745
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/common/components/configurationForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
HARD_DRIVE_SSD,
HARD_DRIVE_SAN,
HARD_DRIVE_HDD,
SIZE_UNIT_GB
SIZE_UNIT_GB,
MAX_NUMERIC_VALUE
} from '@features/configuration/constants'

import './configuration-form.css'
Expand Down Expand Up @@ -182,9 +183,8 @@ const ConfigurationForm = () => {
autoCorrect="off"
autoCapitalize="none"
min={1}
max={9999}
step={1}
pattern="[0-9]{1,4}"
max={MAX_NUMERIC_VALUE}
step="any"
placeholder="Number of CPUs (optional)"
label="Number of CPUs"
tooltip={
Expand All @@ -203,9 +203,9 @@ const ConfigurationForm = () => {
autoCorrect="off"
autoCapitalize="none"
min={20}
max={9999}
max={MAX_NUMERIC_VALUE}
step={1}
pattern="[0-9]{1,4}"
pattern="[0-9]{1,6}"
placeholder="Number of Connections (optional)"
label="Number of Connections"
tooltip="Maximum number of PostgreSQL client connections"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const TotalMemoryInput = ({ tooltip }) => {
autoCapitalize="none"
required="required"
min={1}
max={9999}
max={Number.MAX_SAFE_INTEGER}
step={1}
pattern="[0-9]{1,4}"
placeholder="Memory size (RAM, required)"
Expand Down
10 changes: 5 additions & 5 deletions src/common/components/configurationForm/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
SIZE_UNIT_GB,
HARD_DRIVE_HDD,
HARD_DRIVE_SSD,
HARD_DRIVE_SAN
HARD_DRIVE_SAN,
MAX_NUMERIC_VALUE
} from '@features/configuration/constants'

const MAX_INTEGER = 9999
const MIN_MB_MEMORY = 512

const DB_TYPES = [DB_TYPE_WEB, DB_TYPE_OLTP, DB_TYPE_DW, DB_TYPE_DESKTOP, DB_TYPE_MIXED]
Expand All @@ -39,20 +39,20 @@ export const validationSchema = Yup.object().shape({
}
return schema.min(1, 'Must be greater than zero')
})
.max(MAX_INTEGER, `Must be less than or equal to ${MAX_INTEGER}`),
.max(MAX_NUMERIC_VALUE, `Must be less than or equal to ${MAX_NUMERIC_VALUE}`),
hdType: Yup.string().required('Required').oneOf(HARD_DRIVE_TYPES, 'Unsupported hard drive'),
cpuNum: Yup.number()
.transform((value) => (isNaN(value) ? null : value))
.nullable()
.notRequired()
.integer('Must be an integer')
.min(1, 'Must be greater than zero')
.max(MAX_INTEGER, `Must be less than or equal to ${MAX_INTEGER}`),
.max(MAX_NUMERIC_VALUE, `Must be less than or equal to ${MAX_NUMERIC_VALUE}`),
connectionNum: Yup.number()
.transform((value) => (isNaN(value) ? null : value))
.nullable()
.notRequired()
.integer('Must be an integer')
.min(20, 'Must be greater than or equal to 20')
.max(MAX_INTEGER, `Must be less than or equal to ${MAX_INTEGER}`)
.max(MAX_NUMERIC_VALUE, `Must be less than or equal to ${MAX_NUMERIC_VALUE}`)
})
2 changes: 2 additions & 0 deletions src/features/configuration/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export const SIZE_UNIT_GB = 'GB'
export const HARD_DRIVE_SSD = 'ssd'
export const HARD_DRIVE_SAN = 'san'
export const HARD_DRIVE_HDD = 'hdd'
// maximum value for integer fields
export const MAX_NUMERIC_VALUE = 999999

0 comments on commit b9e7745

Please sign in to comment.