Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

tjohnston-softdev/ip-mac-validator-comparisons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP/MAC Address Validator Comparisons


As of 8 April 2022, this repository has been discontinued


This is a demo project that compares IP and MAC Address string validation between different libraries. The idea is to validate a given string using a heavy and a lighter validation library to see whether the results match.

Now, I love the validator library, I really do. However, I try to avoid unnecessary bloat in my projects. When you install 'validator', you install the whole suite of functions regardless of whether you actually plan on using them or not. This is fine when you're validating a wide variety of input but if its for just one or two types, it is a little excessive. Why download a ~700kb library full of stuff you're not going to use when the ~10kb library accomplishes the same thing? I ended up downsizing in one of my projects and it made no difference at all.

At the same time, I am well aware that just because the outcome is the same, that does not mean that the libraries function in exactly the same way. I felt the need to downsize in one of my other projects so I decided to put together a little experiment.

This unit testing project runs validation on different input strings using two different libraries. One of them is the classic 'validator' library and the other is a lighter alternative. If the two results match, that means the validation is the same. Otherwise, we know the libraries function differently enough to affect the outcome.

In doing this, I am not implying that one library is better than the other. All this proves is that while two libraries may appear to function the same, they can still produce different results depending on the input. I think it is up to you to decide which library is appropriate for which situation, and what trade-offs you might consider.


Usage

  1. Open a terminal inside the project folder.
  2. Run npm install
  3. Run npm test to perform the unit tests.

Libraries Used

  • validator - Classic, heavy validation library.
  • ip-regex - Lighter alternative for IP Addresses.
  • mac-regex - Lighter alternative for MAC Addresses.
  • mocha, chai - Unit testing framework.

Credits


Disclaimer

This demo project is licensed under CC0 1.0 Universal. I only wrote this as an experiment to compare the results of different validation libraries. This is not an official project in any capacity. I have no affiliation with the respective developers nor their contributors. While I will make an effort to maintain this repository where applicable, I do not accept any responsibility for how you use this code or how you interpret the test results.

About

DISCONTINUED - Compares IP and MAC Address string validation between the heavy 'validator' library and lightweight alternatives.

Topics

Resources

License

Stars

Watchers

Forks