/* eslint-disable */
export const inputValidation = (value: string, regexp: RegExp) => {
  return value.match(regexp);
};

export const validationIp = (
  _: any,
  value: string,
  translation: string,
): Promise<void> => {
  const regexp =
    /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;

  if (value && inputValidation(value, regexp)) {
    return Promise.resolve();
  }
  return Promise.reject(new Error(translation));
};
