Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export const DBClusterAdvancedOptions: FC<DBClusterAdvancedOptionsProps> = ({
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' };
Expand Down
10 changes: 10 additions & 0 deletions public/app/percona/shared/helpers/validators.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
7 changes: 7 additions & 0 deletions public/app/percona/shared/helpers/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;