Fix some typing problems

- Using '' as default value is confusing when the function expects a number
  as parameter
- `validateRequiredValue` can take a number as well as a string as first
  parameter
This commit is contained in:
jvoisin 2020-12-22 13:18:14 +01:00
parent bdff46ec1d
commit 07497beb78
2 changed files with 3 additions and 3 deletions

View file

@ -190,7 +190,7 @@ export const getIpList = (interfaces) => Object.values(interfaces)
.reduce((acc, curr) => acc.concat(curr.ip_addresses), []) .reduce((acc, curr) => acc.concat(curr.ip_addresses), [])
.sort(); .sort();
export const getDnsAddress = (ip, port = '') => { export const getDnsAddress = (ip, port = 0) => {
const isStandardDnsPort = port === STANDARD_DNS_PORT; const isStandardDnsPort = port === STANDARD_DNS_PORT;
let address = ip; let address = ip;
@ -205,7 +205,7 @@ export const getDnsAddress = (ip, port = '') => {
return address; return address;
}; };
export const getWebAddress = (ip, port = '') => { export const getWebAddress = (ip, port = 0) => {
const isStandardWebPort = port === STANDARD_WEB_PORT; const isStandardWebPort = port === STANDARD_WEB_PORT;
let address = `http://${ip}`; let address = `http://${ip}`;

View file

@ -16,7 +16,7 @@ import { getLastIpv4Octet, isValidAbsolutePath } from './form';
// https://redux-form.com/8.3.0/examples/fieldlevelvalidation/ // https://redux-form.com/8.3.0/examples/fieldlevelvalidation/
// If the value is valid, the validation function should return undefined. // If the value is valid, the validation function should return undefined.
/** /**
* @param value {string} * @param value {string|number}
* @returns {undefined|string} * @returns {undefined|string}
*/ */
export const validateRequiredValue = (value) => { export const validateRequiredValue = (value) => {