Gathering detailed insights and metrics for @utils-fns/validators
Gathering detailed insights and metrics for @utils-fns/validators
Gathering detailed insights and metrics for @utils-fns/validators
Gathering detailed insights and metrics for @utils-fns/validators
npm install @utils-fns/validators
Typescript
Module System
Node Version
NPM Version
Total Downloads
5,619
Last Day
17
Last Week
42
Last Month
171
Last Year
3,133
Minified
Minified + Gzipped
Latest Version
10.0.0
Package Id
@utils-fns/validators@10.0.0
Unpacked Size
6.52 MB
Size
743.98 kB
File Count
485
NPM Version
9.5.0
Node Version
18.15.0
Published on
Aug 08, 2023
Cumulative downloads
Total Downloads
Last Day
240%
17
Compared to previous day
Last Week
110%
42
Compared to previous week
Last Month
56.9%
171
Compared to previous month
Last Year
26%
3,133
Compared to previous year
The @utils-fns/validators library was developed to be part of a larger library, @utils-fns, which is being developed with the aim of providing unified tools that facilitate the daily tasks of programmers. Our motivation is to simplify common tasks, such as validators, value masking, sorting, search and conversion methods, offering a comprehensive and efficient solution that makes possible the use of this set of libraries in web - mobile - service environments.
@utils-fns/validators
library provides the following validators:If you want to install the complete module, follow the documents in the @utils-fns/utils-fns.
To install the @utils-fns/validators library: use your preferred package manager
1 yarn add @utils-fns/validators 2 3 or 4 5 npm install @utils-fns/validators
To access the features, just follow the example:
1 //ES6 2 import { validators } from "@utils-fns/validators";
1 //CommomJS 2 const { validators } = require("@utils-fns/validators");
So, just choose which validation tool will be used.
1 const cpfValidation = validators.cpf('64912007013') 2 //return true
@utils-fns/validators
is written in TypeScript with complete definitions.
Method | Params | Type |
---|---|---|
cpf | cpf | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.cpf('64912007013') 4 //✅ return true 5 6 validators.cpf('649.120.070-13') 7 //✅ return true 8 9 validators.cpf('01234598329') 10 //❌ return false
Method | Params | Type |
---|---|---|
nis | nis | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.nis('90152083257') 4 //✅ return true 5 6 validators.nis('901.52083.25-7') 7 //✅ return true 8 9 validators.nis('00000000000') 10 //❌ return false
Method | Params | Type |
---|---|---|
email | email | string | undefined |
email | paramsEmailValidator.minMaxUserNameEmail.min | number | undefined |
email | paramsEmailValidator.minMaxUserNameEmail.max | number | undefined |
email | paramsEmailValidator.minMaxEmailDomain.min | number | undefined |
email | paramsEmailValidator.minMaxEmailDomain.max | number | undefined |
email | paramsEmailValidator.emailDomainName | RegExp | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.email({ email: 'foobar@validator.com' }) 4 //✅ return true 5 6 validators.email({ email: 'fóobar@validatior.com' }) 7 //❌ return false 8 9 validators.email({ 10 email: 'foobar@gmail.com', 11 paramsEmailValidator: { 12 emailDomainName: RegExp(/(gmail.com|hotmail.com)/) 13 }, 14 }) 15 //✅ return true 16 17 validators.email({ 18 email: 'foobar@validator.com', 19 paramsEmailValidator: { 20 emailDomainName: RegExp(/(gmail.com|hotmail.com)/) 21 }, 22 }) 23 //❌ return false
Method | Params | Type |
---|---|---|
cnpj | cnpj | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.cnpj('22014929000102') 4 //✅ return true 5 6 validators.cnpj('22.014.929/0001-02') 7 //✅ return true 8 9 validators.cnpj('01234569841234') 10 //❌ return false
Method | Params | Type |
---|---|---|
phone | phone | string | undefined |
phone | paramsPhoneValidator.onlyMobilePhoneBR | boolean | undefined |
phone | paramsPhoneValidator.canReceiveInternationalNumbers | boolean | undefined |
phone | paramsPhoneValidator.customPatternPhone.coutryCode | RegExp |
phone | paramsPhoneValidator.customPatternPhone.areaStateCode | RegExp |
phone | paramsPhoneValidator.customPatternPhone.phoneNumber | RegExp |
phone | paramsPhoneValidator.publicUtilityNumberBR | boolean | undefined |
phone | paramsPhoneValidator.numberWithoutCodeAreas | boolean | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.phone({ phone: '(63) 92102-2418' }) 4 //✅ return true 5 6 validators.phone({ phone: '63921022418' }) 7 //✅ return true 8 9 validators.phone({ phone: '988283' }) 10 //❌ return false 11 12 validators.phone({ phone: '190', { 13 publicUtilityNumberBR: true 14 } }) 15 //✅ return true 16 17 validators.phone({ phone: '(11) 99385-3318', { 18 numberWithoutCodeAreas: true 19 } }) 20 //❌ return false 21 22 validators.phone({ phone: '66934451006', { 23 canReceiveInternationalNumbers: true, 24 customPatternPhone: { 25 coutryCode: RegExp(/66/), 26 areaStateCode: RegExp(/9{0,1}/), 27 phoneNumber: RegExp(/([2-9]{1}\d{6,7})$/), 28 } 29 } 30 }) 31 //✅ return true 32 33 validators.phone({ phone: '+1 (541) 708-3275', { 34 canReceiveInternationalNumbers: true 35 } 36 }) 37 //✅ return true
Method | Params | Type |
---|---|---|
paymentCard | cardNumber | string | undefined |
paymentCard.isValid | paramsPaymentCardValidator.validationTypeCard | credit | debit | credit-debit | undefined |
paymentCard.isValid | paramsPaymentCardValidator.specificBrandCard | american-express | diners-club | discover | elo | hiper | hipercard | jcb | maestro | mastercard | mir | unionpay | visa | visa-electron | undefined |
paymentCard.isValid | paramsPaymentCardValidator.customPatternPaymentCard | RegExp | undefined |
paymentCard.getData | - | - |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.paymentCard({ cardNumber: '4024 0071 6435 7039' }).getData() 4 //✅ return { 5 // bankDigits: '4', 6 // bankName: 'Visa', 7 // cardNumber: '4024 0071 6435 7039', 8 // isValid: true, 9 // } 10 11 validators.paymentCard({ cardNumber: '4024 0071 6435 7039' }).isValid() 12 //✅ return true 13 14 validators.paymentCard({ cardNumber: '4124007164357039' }).isValid({ 15 customPatternPaymentCard: RegExp(/^4[0-2](\d{14})$/), 16 }) 17 //✅ return true 18 19 validators.paymentCard({ cardNumber: '3014 842898 5841' }).isValid({ 20 specificBrandCard: 'diners-club', 21 }) 22 //✅ return true 23 24 validators.paymentCard({ cardNumber: '3014 842898 5841' }).isValid({ 25 specificBrandCard: 'visa', 26 }) 27 //❌ return false
Method | Params | Type |
---|---|---|
paymentSlip | digits | string | undefined |
paymentSlip.isValid | paramsPaymentSlipValidator.validByBank | BankCode | BankName | undefined |
paymentSlip.isValid | paramsPaymentSlipValidator.validSegmentType | Taxas Municipais | Taxas de Saneamento | Taxas de Energia Elétrica e Gás | Taxas de Telecomunicações | Taxas de Órgãos Governamentais | Taxas de Trânsito | Uso Exclusivo dos Bancos | Pagamento de Boletos Bancários | Outros | undefined |
paymentSlip.isValid | paramsPaymentSlipValidator.validByPrice | string | number | undefined |
paymentSlip.isValid | paramsPaymentSlipValidator.validByDate | string | Date | undefined |
paymentSlip.isValid | paramsPaymentSlipValidator.validByTypeOfPaymentSlip | Boleto Bancário |
paymentSlip.isValid | paramsPaymentSlipValidator.validByIfIsBarCodeOrTypeableLine | Cód. Barras | Linha Digitável | undefined |
paymentSlip.getData | - | - |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.paymentSlip({ digits: '65591942700000005000000000442500009390032700' }).getData() 4 //✅ return { 5 // bankCode: '655', 6 // bankName: 'Banco Votorantim S.A.', 7 // barCodeOrTypeableLine: 'Cód. Barras', 8 // digits: '65591942700000005000000000442500009390032700', 9 // expirationDate: '30/07/2023', 10 // price: '5.00', 11 // segmentPaymentSplip: 'Pagamento de Boletos Bancários', 12 // typeOfPaymentSlip: 'Boleto Bancário', 13 // isValid: true, 14 // } 15 16 validators.paymentSlip({ digits: '65591942700000005000000000442500009390032700' }).isValid() 17 //✅ return true 18 19 validators.paymentSlip({ digits: '65591942700000005000000000442500009390032700' }).isValid({ 20 validByTypeOfPaymentSlip: 'Boleto Bancário' 21 }) 22 //✅ return true 23 24 validators.paymentSlip({ digits: '65591942700000005000000000442500009390032700' }).isValid({ 25 validByTypeOfPaymentSlip: 'Boleto de Arrecadação' 26 }) 27 //❌ return false 28 29 validators.paymentSlip({ digits: '84610000000319901090110049617944480805321901' }).isValid({ 30 validByPrice: '31.99', 31 validSegmentType: 'Taxas de Telecomunicações', 32 validByIfIsBarCodeOrTypeableLine: 'Cód. Barras', 33 validByTypeOfPaymentSlip: 'Boleto de Arrecadação', 34 }) 35 //✅ return true 36 37 validators.paymentSlip({ digits: '65590000020044250000594059050008194290000006050' }).isValid({ 38 validByBank: '655', 39 validByDate: '08-01-2023', 40 validByPrice: 60.5, 41 validSegmentType: 'Pagamento de Boletos Bancários', 42 validByIfIsBarCodeOrTypeableLine: 'Linha Digitável', 43 validByTypeOfPaymentSlip: 'Boleto Bancário', 44 }) 45 //✅ return true
Method | Params | Type |
---|---|---|
stateRegistrationValidator | digits | string | undefined |
stateRegistrationValidator | uf | AC | AL | AP | AM | BA | CE | DF | ES | GO | MA | MT | MS | MG | PA | PB | PR | PE | PI | RJ | RN | RS | RO | RR | SC | SP | SE | TO |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.stateRegistrationValidator({ digits: '746943024', uf: 'PB' }) 4 //✅ return true 5 6 validators.stateRegistrationValidator({ digits: '746943024', uf: 'SP' }) 7 //❌ return false
Method | Params | Type |
---|---|---|
voterRegistrationValidation | digits | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.voterRegistration('613752510213') 4 //✅ return true 5 6 validators.voterRegistration('0123.4567.8901') 7 //❌ return false
Method | Params | Type |
---|---|---|
cnh | cnh | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.cnh('45426105401') 4 //✅ return true 5 6 validators.cnh('703417160228787182') 7 //❌ return false
Method | Params | Type |
---|---|---|
renavamValidator | renavam | string | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.renavam('08804737318') 4 //✅ return true 5 6 validators.renavam('703417160228787182') 7 //❌ return false
Method | Params | Type |
---|---|---|
cep | cep | string | undefined |
cep.isValid | - | - |
cep.getData | signal | AbortSignal | null | undefined |
1 import { validators } from "@utils-fns/validators"; 2 3 validators.cep('01001000').isValid() 4 //✅ return true 5 6 await validators.cep('01001000').getData() 7 //✅ return { 8 // estado: 'São Paulo', 9 // uf: 'SP', 10 // complemento: '- lado ímpar', 11 // cep: '01001-000', 12 // cidade: 'São Paulo', 13 // bairro: 'Sé', 14 // logradouro: 'Praça da Sé', 15 // enderecoPostal: 'Praça da Sé, lado ímpar, Sé, 01001-000, São Paulo/SP', 16 // isValid: true, 17 // }
This API is licensed MIT.
No vulnerabilities found.
No security vulnerabilities found.