1.3.0 • Published 2 months ago

nebur-regex v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Nebur-Regex 🚀

Nebur-Regex is a powerful utility package designed to streamline the developer experience with regular expressions. With an intuitive and expressive API, it provides a convenient way to create, combine, and apply regular expression validation rules in your JavaScript or TypeScript projects.

Key Features:

  • 🧩 Predefined rules for common use cases such as alphanumeric, email, numeric, phone number, URL, and more.
  • 🛠️ Easy-to-use methods for adding custom rules and patterns.
  • ❄️ Immutable instances to ensure rule sets are maintained consistently.
  • 🚀 Clear and concise syntax for building complex validation logic effortlessly.
  • ❄️ Frozen instances for enhanced predictability and reliability.

Simplify your regular expression handling and validation tasks with nebur-regex, making it easier and more enjoyable to work with regex in your applications.

Installation

$ npm install nebur-regex

Quick exqmple

import { iWantRegex } from 'nebur-regex'; // ES6 module
//OR
const { iWantRegex } = require('nebur-regex'); // CommonJs

const constraints = 
  iWantRegex()
  .toContains('@')
  .toBeEmail()
  .end();

const isValid = constraints.test("test@test.com");

console.log(isValid); //true

More examples

import { iWantRegex } from 'nebur-regex';

// Creating a set of regex constraints using 'iWantRegex', chaining various rules.
const constraints = 
  iWantRegex() // Initializing the regex constraint builder
  .toBeAlphanumeric() // Enforcing alphanumeric characters only
  .toBeCreditCardNumber() // Ensuring a valid credit card number format
  .toBeDate() // Checking if the input is a valid date => Format: MM/DD/YYYY | M/D/YYYY | MM-DD-YYYY | M-D-YYYY
  .toBeEmail() // Validating the input as an email address
  .toBeHexColor() // Confirming the input is a valid hex color code
  .toBeLowercase() // Verifying that all characters are in lowercase
  .toBeNumeric() // Ensuring the input consists of numeric characters only
  .toBePhoneNumber() // Validating the input as a phone number
  .toBeURL() // Checking if the input is a valid URL
  .toBeUppercase() // Verifying that all characters are in uppercase
  .toContains('hi') // Checking if the input contains the substring 'hi'
  .toMatch(/^([0-9]+)$/) // Ensuring the input matches the specified regex pattern (only digits)
  .end(); // Always End the chaining of regex constraints

// Testing the constraints against the string "hello world"
const isValid = constraints.test("hello world"); 

// Logging the result of the validation
console.log('isValid', isValid); // false;

Stay in touch

License

Click here 👉 More details

1.3.0

2 months ago

1.2.1

2 months ago

1.2.0

2 months ago

1.1.8

3 months ago

1.1.11

3 months ago

1.1.10

3 months ago

1.1.3

3 months ago

1.1.2

3 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.12

3 months ago

1.0.11

3 months ago

1.0.10

3 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago