Skip to content

Commit

Permalink
fix: improved IPv4 regex
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Sep 28, 2022
1 parent 4e9b506 commit 49c046f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import React from 'react';

const validateInventoryAndGroup = (validationObj) => {

/*
'errors' is an object storing error messages for each field.
Each property is a list of errors for the respective field.
*/

let errors = {
groupName: [],
address: [],
Expand Down Expand Up @@ -33,7 +38,7 @@ const validateInventoryAndGroup = (validationObj) => {
errors.address.push(err);
isValid = false;
}else if (Number.isInteger(Number(validationObj.address.charAt(0))) || validationObj.hasOwnProperty("onlyAdress")){
let doesMatch = validationObj.address.match(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/);
let doesMatch = validationObj.address.match(/^(([1-9]{1}[0-9]{0,2})|(0))\.(([1-9]{1}[0-9]{0,2})|(0))\.(([1-9]{1}[0-9]{0,2})|(0))\.(([1-9]{1}[0-9]{0,2})|(0))$/);
let octetsValid = true;
if (doesMatch){
let octets = validationObj.address.split(".");
Expand Down

0 comments on commit 49c046f

Please sign in to comment.