Skip to content

Commit

Permalink
Merge pull request #102 from jmealo/feat/issue-101
Browse files Browse the repository at this point in the history
Feature: Remove arbitrary maximum integer values. Implements #101
  • Loading branch information
le0pard authored Nov 29, 2024
2 parents b3c16bd + 61b0d0b commit 3947f47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
11 changes: 6 additions & 5 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,9 @@ const ConfigurationForm = () => {
autoCorrect="off"
autoCapitalize="none"
min={1}
max={9999}
max={MAX_NUMERIC_VALUE}
step={1}
pattern="[0-9]{1,4}"
pattern="[0-9]{1,6}"
placeholder="Number of CPUs (optional)"
label="Number of CPUs"
tooltip={
Expand All @@ -203,9 +204,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
6 changes: 3 additions & 3 deletions src/common/components/configurationForm/totalMemoryInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Field } from 'formik'
import Tooltip from '@common/components/form/tooltip'
import FormSimpleField from '@common/components/form/simpleField'
import FormSimpleDropdown from '@common/components/form/simpleDropdown'
import { SIZE_UNIT_MB, SIZE_UNIT_GB } from '@features/configuration/constants'
import { SIZE_UNIT_MB, SIZE_UNIT_GB, MAX_NUMERIC_VALUE } from '@features/configuration/constants'

import './total-memory-input.css'

Expand Down Expand Up @@ -47,9 +47,9 @@ const TotalMemoryInput = ({ tooltip }) => {
autoCapitalize="none"
required="required"
min={1}
max={9999}
max={MAX_NUMERIC_VALUE}
step={1}
pattern="[0-9]{1,4}"
pattern="[0-9]{1,6}"
placeholder="Memory size (RAM, required)"
/>
<Field
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 3947f47

Please sign in to comment.