npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@doutor.space/is-valid

v1.0.7

Published

[![Maintainability](https://api.codeclimate.com/v1/badges/2fc45a75c598ce6fbe3c/maintainability)](https://codeclimate.com/repos/5e1489d3330ae320e5002e87/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/2fc45a75c598ce6fbe3c/test_cove

Downloads

10

Readme

@doutor.space/is-valid

Maintainability Test Coverage

Pacote com validações comuns para node.js.

Uso

# npm
npm install @doutor.space/is-valid

# yarn
yarn add @doutor.space/is-valid
// Em ES5
const isValid = require('@doutor.space/is-valid');
// ou em ES6
import * as isValid from '@doutor.space/is-valid';

isPhone

Valida se a sequência de números é compativel com a quantidade de números de um telefone no formado (xx) xxxxx-xxxx.

Use uma das opções:

// ES5
const isValid = require('@doutor.space/is-valid');
const { isPhone } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isPhone } from '@doutor.space/is-valid';
const result = isPhone(12312312312);
console.log(result); /// true

const result = isPhone('1231z312x12');
console.log(result); /// false

const result = isPhone('123122231212');
console.log(result); /// false

isSafePassword

Valida se a senha tem o mínimo se segurança necessária. Há 3 níveis:

  • 1 - Soft: Aceita ao mínimo 1 letras e 1 números, com no mínimo 6 caracteres.
  • 2 - Medium: Aceita ao mínimo 1 letras e 1 números e 1 caractere especial, com no mínimo 6 caracteres.
  • 3 - Strong: Aceita ao mínimo 1 letras e 1 números e 1 caractere especial, com no mínimo 8 caracteres.

Use uma das opções:

// ES5
const isValid = require('@doutor.space/is-valid');
const { isSafePassword } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isSafePassword } from '@doutor.space/is-valid';
const result = isSafePassword('abc123');
console.log(result); /// true

const result = isSafePassword('abc123', 2);
console.log(result); /// false

const result = isSafePassword('89as76d9asd');
console.log(result); /// true

isCPF

Valida se a númeração é compativel com o CPF brasileiro e se é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isCPF } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isCPF } from '@doutor.space/is-valid';
const result = isCPF('341.835.233-20');
console.log(result); /// true

const result = isCPF('77148782155');
console.log(result); /// true

const result = isCPF('15771548782');
console.log(result); /// false

isCNPJ

Valida se a númeração é compativel com o CNPJ brasileiro e se é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isCNPJ } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isCNPJ } from '@doutor.space/is-valid';
const result = isCNPJ('11.558.258/0001-24');
console.log(result); /// true

const result = isCNPJ('28927148000195');
console.log(result); /// true

const result = isCNPJ('28149270180095');
console.log(result); /// false

isJson

Valida se a string json é valida.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isJson } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isJson } from '@doutor.space/is-valid';
const result = isJson('{}');
console.log(result); /// true

const result = isJson('{"a": true}');
console.log(result); /// true

const result = isJson('[q]');
console.log(result); /// false

isTime

Valida se o horário é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isTime } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isTime } from '@doutor.space/is-valid';
const result = isTime('12:60');
console.log(result); /// false

const result = isTime('34534');
console.log(result); /// false

const result = isTime('12:12');
console.log(result); /// true

isEmail

Valida se o email é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isEmail } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isEmail } from '@doutor.space/is-valid';
const result = isEmail('[email protected]');
console.log(result); /// true

const result = isEmail('[email protected]');
console.log(result); /// false

const result = isEmail('[email protected]');
console.log(result); /// true

isSlug

Valida se o slug é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isSlug } = require('@doutor.space/is-valid');

// ES6
import isValid from '@doutor.space/is-valid';
import { isSlug } from '@doutor.space/is-valid';
const result = isSlug('[email protected]');
console.log(result); /// false

const result = isSlug('abc-com');
console.log(result); /// true

const result = isSlug('abc-etc-digital');
console.log(result); /// true

stringSize

Valida se a string tem um tamanho é valido.

// ES5
const isValid = require('@doutor.space/is-valid');
const { stringSize } = require('@doutor.space/stringSize');

// ES6
import isValid from '@doutor.space/is-valid';
import { stringSize } from '@doutor.space/is-valid';
const result = stringSize('ab');
console.log(result); /// false

const result = stringSize('abc-com');
console.log(result); /// true

const result = stringSize('abc etc digital', 3, 100);
console.log(result); /// true

isDateString

Valida se a data em formato string é valida.

// ES5
const isValid = require('@doutor.space/is-valid');
const { isDateString } = require('@doutor.space/isDateString');

// ES6
import isValid from '@doutor.space/is-valid';
import { isDateString } from '@doutor.space/is-valid';
const result = isDateString('20190104');
console.log(result); /// true

const result = isDateString('201901');
console.log(result); /// true

const result = isDateString('1090-12-12', 1990);
console.log(result); /// false