mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(app): autoscaling min validation [EE-6387] (#10945)
This commit is contained in:
parent
b3b7cfa77f
commit
3a959208a8
2 changed files with 19 additions and 20 deletions
|
@ -12,26 +12,25 @@ export function autoScalingValidation(
|
|||
const { autoScalerOverflow } = validationData || {};
|
||||
return object({
|
||||
isUsed: boolean().required(),
|
||||
minReplicas: number()
|
||||
.min(0, 'Minimum instances must be greater than 0.')
|
||||
.when('isUsed', (isUsed: boolean) =>
|
||||
isUsed
|
||||
? number()
|
||||
.required('Minimum instances is required.')
|
||||
.test(
|
||||
'maxReplicas',
|
||||
'Minimum instances must be less than maximum instances.',
|
||||
// eslint-disable-next-line func-names
|
||||
function (this, value?: number): boolean {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
const { maxReplicas } = this.parent as AutoScalingFormValues;
|
||||
return !maxReplicas || value < maxReplicas;
|
||||
minReplicas: number().when('isUsed', (isUsed: boolean) =>
|
||||
isUsed
|
||||
? number()
|
||||
.required('Minimum instances is required.')
|
||||
.min(1, 'Minimum instances must be greater than 0.')
|
||||
.test(
|
||||
'maxReplicas',
|
||||
'Minimum instances must be less than maximum instances.',
|
||||
// eslint-disable-next-line func-names
|
||||
function (this, value?: number): boolean {
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
)
|
||||
: number()
|
||||
),
|
||||
const { maxReplicas } = this.parent as AutoScalingFormValues;
|
||||
return !maxReplicas || value < maxReplicas;
|
||||
}
|
||||
)
|
||||
: number()
|
||||
),
|
||||
maxReplicas: number().when('isUsed', (isUsed: boolean) =>
|
||||
isUsed
|
||||
? number()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue