1.0.6 • Published 1 year ago

@achmadeko003/validate v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Validate

A package for validate.

Feature

Installation

$ npm i @achmadeko003/validate

Email

A function for validate email with a custom format.

usage:

import { isEmail } from "@achmadeko003/validate/index";

isEmail("Pururu003@gmail.com"); // Basic usage
// true

isEmail("Pururu003@outlook.com", {
  gmail: true,
  outlook: true,
  yahoo: true,
  hotmail: true,
}); // Famous email domain
// true

isEmail("Pururu003@madko.com", { custom: "madko.com" }); // Custom email domain
// true

isEmail("Pururu003@madko.com", { firstLetter: 3, mask: "*" }); // Mask email
// Pur******@madko.com

String

A function for validate string.

usage:

import { isString } from "@achmadeko003/validate/index";

new isString("pururu").check(); // Basic usage for validate value type is string or not
new isString("pururu!").useSymbols().check(); // Add useSymbols() for excluded symbols
new isString("pururu2").useNumber().check(); // Add useNumber() for excluded symbols
new isString("pururu").useSymbols().useNumber().check(); // or add useSymbols() and useNumber() for exluded character symbols and number
new isString("pururu2").maxLength(3); // Add maxLength() for check string length
new isString("https://example.com").checkLinkURL(); // checkLinkURL() for validate if string is https:// or http:// URL

Object

A function for validate value is object or not.

usage:

import { isObject } from "@achmadeko003/validate/index";

const profile = {
  id: 10,
  name: "Pururu",
  phone: null,
  email: "Pururu003@gmail.com",
  address: null,
};

new isObject(profile).check(); // Basic usage
// true

new isObject(profile).valueNull(); // Validate object key values
// {
//  status: true,
//  detail: [
//    'phone value is null or undefined',
//    'address value is null or undefined'
//  ]
// }

new isObject(profile).setKeys(["phone", "email"]).valueNull(); // Validate specific object key values
// {
//  status: true,
//  detail: [
//    'phone value is null or undefined'
//  ]
// }

Empty

A function for validate field null or undefined.

usage:

import { isEmpty } from "@achmadeko003/validate/index";

const phoneNumber = null;

isEmpty(phoneNumber); // Basic usage that return true if value null or undefined
1.0.2

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago