in desktop/src/app/components/pool/network-configuration/pool-endpoint-helper.ts [24:63]
export function backendPortValidator(inboundNATPools: InboundNATPoolAttributes[]) {
return (control: FormControl): {[key: string]: any} => {
if (control.value === null) {
return null;
}
if (inboundNATPools) {
let hasDuplicate = false;
if (inboundNATPools) {
for (const pool of inboundNATPools) {
if (control.value === pool.backendPort) {
hasDuplicate = true;
break;
}
}
}
if (hasDuplicate) {
return {
duplicateValue: {
value: control.value,
},
};
}
}
if (control.value < MININUM_PORT || control.value > MAXIMUM_BACKEND_PORT) {
return {
invalidRange: {
value: control.value,
},
};
}
if (RESERVED_BACKEND_PORT.includes(control.value)) {
return {
reservedPort: {
value: control.value,
},
};
}
return null;
};
}