diff --git a/public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/DBClusterAdvancedOptions.tsx b/public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/DBClusterAdvancedOptions.tsx index 1328dfc7b7068..e783da8b441b1 100644 --- a/public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/DBClusterAdvancedOptions.tsx +++ b/public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/DBClusterAdvancedOptions.tsx @@ -66,10 +66,10 @@ export const DBClusterAdvancedOptions: FC = ({ const [loadingExpectedResources, setLoadingExpectedResources] = useState(false); const mounted = { current: true }; - const { required, min } = validators; + const { required, min, int32 } = validators; const { change } = form; const diskValidators = [required, min(MIN_DISK_SIZE)]; - const nodeValidators = [required, min(MIN_NODES), nodesValidator]; + const nodeValidators = [required, min(MIN_NODES), nodesValidator, int32]; const parameterValidators = [required, min(MIN_RESOURCES), resourceValidator]; const { name, kubernetesCluster, topology, resources, memory, cpu, databaseType, disk, nodes, single } = values; const resourcesInputProps = { step: '0.1' }; diff --git a/public/app/percona/shared/helpers/validators.test.tsx b/public/app/percona/shared/helpers/validators.test.tsx index b62af3e245a26..ef4ed601abf4a 100644 --- a/public/app/percona/shared/helpers/validators.test.tsx +++ b/public/app/percona/shared/helpers/validators.test.tsx @@ -214,3 +214,13 @@ describe('validators compose', () => { expect(validate(120, {})).toEqual(errorMessage); }); }); + +describe('Validate int32 test', () => { + it('Validator should return undefined if the passed value is int32', () => { + // TODO + }); + + it('Validator should return error if the passed value is not int32', () => { + // TODO + }); +}); diff --git a/public/app/percona/shared/helpers/validators.ts b/public/app/percona/shared/helpers/validators.ts index b973e443ea52b..e65a15f3eab97 100644 --- a/public/app/percona/shared/helpers/validators.ts +++ b/public/app/percona/shared/helpers/validators.ts @@ -109,6 +109,13 @@ export const validators = { return result; }, + int32: (value: string) => { + if (Math.abs(+value) <= 2147483647) { + return undefined; + } + + return `The number of nodes is too large`; + }, }; export default validators;