
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
epic-validator
Advanced tools
A simple but powerful Data Validator Library. This library will allow you to validate data with less code and more power. You can use this library with any framework.
Epic Validator is very easy to use library. View the documentation below to start working with Epic Validator quickly!
Follow the below method to validate a value
import { Validation } from "epic-validator";
// Create a Validator Instance.
// You can also pass an object containing your custom validators
const Validator = new Validation({
// Your custom IP Address validator
isIP: (_) =>
_.matches(
/^((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]?)$/,
"Please provide a valid IP Address!"
),
// Your custom IBAN validator
isIBAN: (_) =>
_.matches(
/^([A-Z]{2}[ -]?[0-9]{2})(?=(?:[ -]?[A-Z0-9]){9,30}$)((?:[ -]?[A-Z0-9]{3,5}){2,7})([ -]?[A-Z0-9]{1,3})?$/,
"Invalid IBAN Number has been provided!"
),
});
(async () => {
// Example 1:
const Username = "john";
// Validate Value
await Validator.validate(Username)
.isAlphanumeric(
{
allowSpaces: false, // Set to True if spaces allowed.
strict: true, // Set to False if symbols allowed.
},
// Provide a Validation message
"Please provide a valid Username!"
)
/**
* Use exec() method to run the validator and throw the errors if any.
* You can also use run() method but if there are any errors, you will need to throw errors manually.
* You can use Validator.throw() method to throw any errors manually.
*/
.exec();
// Example 2:
const Email = "john@gmail.com";
// Validate Email
await Validator.validate(Email)
.isEmail("Please provide a valid Email!")
.run();
// Throw Errors if any
Validator.throw();
// Example 3:
const Contact = 092384758399;
// Validate Contact using custom() method
await Validator.validate(Contact)
.custom((value, chain) => {
if (typeof value !== "number")
throw "Please provide a valid Contact Number!";
})
.exec();
// Example 4:
const IP = "192.168.2.1";
// Validate IP Address using your custom validator
await Validator.validate(IP).use("isIP").exec();
})();
You can easily validate an Array of Values using the method below.
(async () => {
const Emails = ["john@gmail.com", "abc", "@mail.com"];
// Validate All Emails in the Array
await Validator.validate(Emails)
.each((_) => _.isEmail("Please provide a valid Email!"))
.exec();
})();
It is recommended to validate your data using the schema() method. Follow the method below to validate data schema.
(async () => {
// Dummy Data To Validate
const Data = {
username: "john",
password: "john123",
confirmPassword: "john123",
contact: 03056762589,
agreement: true,
};
// Validate Schema
await Validator.validate(Data).schema({
username: _ => _.isAlphanumeric({}, "Please provide a valid Username!"),
password: _ => _.isString("Please provide a valid Password!").not().isEmpty({}, "Password cannot be empty!"),
confirmPassword: _ => _.isString("Please provide a valid Confirmation Password!").matches(Data.password, "The Confirmation Password doesn't matches your Password!"),
contact: _ => _.isNumeric({
sanitize: true, // Set to True for converting "123" to 123 or "100.2" to 100.2
}, "Please provide a valid Contact Number!"),
agreement: _ => _.likeBoolean({
sanitize: true,
isTrue: true
}, "You need to agree our terms!")
}).exec();
})();
The followings are the available Validators.
The followings are the available Utility Methods.
We have tried our best to make the documentation as simple as possible. Good Luck!
FAQs
A simple but powerful Data Validator
We found that epic-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.