0.0.29 • Published 18 days ago

fogex v0.0.29

Weekly downloads
-
License
MIT
Repository
github
Last release
18 days ago

Fogex

npm version Coverage

Table of Contents

Introduction

I abbreviated the expression "Form Regular Expression" as "FOGEX" to give the library its name. A JavaScript library for quickly and easily testing the validity or invalidity of a value.

Installation

npm install fogex

Usage

1) Use with pre-defined validation functions

isEmail

import { isEmail } from 'fogex'
isEmail('test@test.com') // true
isEmail('test@test') // false

isPhoneNumber

Use with parameter
import { isPhoneNumber } from 'fogex'
isPhoneNumber('+11234567890', 'US') // true
isPhoneNumber('1234567890', 'US') // true
isPhoneNumber('+905555555555', 'US') // true
isPhoneNumber('05555555555', 'US') // true
isPhoneNumber('5555555555', 'US') // true

isPin

Use with parameter
import { isPin } from 'fogex'
isPin('1234', '4') // true
isPin('123456', '6') // true

isCreditCard

import { isCreditCard } from 'fogex'
Default
// Accepts all card types
isCreditCard('XXXX XXXX XXXX XXXX') // true
isCreditCard('XXXXXXXXXXXXXXXX') // true
Use with parameter
isCreditCard('XXXX XXXX XXXX XXXX', 'VISA') // true
isCreditCard('XXXXXXXXXXXXXXXX', 'VISA') // true
isCreditCard('XXXX XXXX XXXX XXXX', 'MASTER') // true
isCreditCard('XXXXXXXXXXXXXXXX', 'MASTER') // true

2) Use with customPattern function

import { customPattern } from 'fogex'

a => a-z

A => A-Z

# => 0-9

! => Special Characters

? => Optional Characters

Example

customPattern('aA#!', 8, 'aA1!1234') //true
customPattern('aA?#!', 5, 'aa11\*') // true

3) Use with GeneratorPattern Class

import { GeneratorPattern } from 'fogex'
const value = 'qweR123!'

const options = {
  minLength: 6,
  maxLength: 12,
  lowerCase: true,
  upperCase: true,
  number: true,
  specialCharacter: true,
}

const validator = new GeneratorPattern(options)
const isValid = validator.validate(value)

console.log(isValid) // true

Pre-defined Regex Functions

TablesDescriptionParameter
isAsciiCheck if the string contains ASCII chars only.
isBooleanCheck if a string is a boolean.
isCase(val, case)Check if the string is a cases.lower, upper, camel, pascal
isColorCode(val, colorCode)Check if the string is a color code.rgb, hex, hsl
isCreditCard(val, cardType)Check if the string is a credit card number. The default value accepts all card typesVISA or MASTER
isEmailCheck if the string is an email.
isFloatCheck if the string is a float.
isHashCheck if the string is a hash of type
isHour(val, hourFormat)Check if the hour format is an correct.12 or 24
isIdentityNumber(val, locale)Check if the string is a identity number.US or TR
isImageUrl(val, extension)Check if the string is a image url. The default value accepts all image extensionpng, jpg, jpeg, gif
isImeiCheck if check if the string is a valid IMEI number.
isIntegerCheck if the string is an integer.
isIpCheck if the string is an IP
isISBNCheck if the string is an ISBN.
isMacCheck if the string is a MAC address.
isMd5Check if the string is a MD5 hash.
isMongoIdCheck if the string is a valid a MongoDB ObjectId.
isMonthCheck if the string is a month.
isPasswordCheck if a password is strong or not.
isPhoneNumber(val, locale)Check if the string is a mobile phone number.US or TR
isPin(val, length)Check if the string is a pin.4 or 6
isPlate(val, locale)Check if string the format of a plate format.US or TR
isPortCheck if the string is a valid port number.
isPostalCode(val, locale)Check if the string is a postal code number.US or TR
isStringCheck if string of a letter
isWhiteSpaceCheck if the string contains white space.

Contribution

Fogex library is under development, and is open to suggestions and contributions.

It is publicly open for any contribution. Bug fixes, new features and extra modules are welcome.

To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.

To report a bug: Please report it using GitHub Issues.

MIT License

Copyright (c) 2022 Emre Yilmaz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.0.29

18 days ago

0.0.28

21 days ago

0.0.27

3 months ago

0.0.24

3 months ago

0.0.25

3 months ago

0.0.26

3 months ago

0.0.22

3 months ago

0.0.23

3 months ago

0.0.20

4 months ago

0.0.21

4 months ago

0.0.18

4 months ago

0.0.19

4 months ago

0.0.17

4 months ago

0.0.15

4 months ago

0.0.16

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.3

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.2

2 years ago

0.0.1

2 years ago