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

validatorjs-aker

v1.0.1

Published

JavaScript library to validate the values of the fields of forms or variables in general

Downloads

5

Readme

JavaScript library to validate the values of the fields of forms or variables in general

Installation

npm i validatorjs-aker

Available languages

  • English ('en') Default
  • Spanish ('es')
  • Italian ('it')
  • Portuguese ('pt')
  • French ('fr')
  • Deutsch ('de')
  • Japanese ('ja')
  • Chinese ('zh')
  • Russian ('ru')

Usage example

import Validator from 'validatorjs-aker'
import it from 'validatorjs-aker/lang/it'

const validator = new Validator()
// const validator = new Validator('es')
// const validator = new Validator(it)

const number = 133
const text = 'John Doe'
const inputLastName = document.querySelector('#last-name')
const inputEmail = document.querySelector('#email')

validator.add(number, 'Number const').required().isNumber().min(150).maxLength(4)
validator.add(text, 'Text const').isString().minLength(3)
validator.add(inputLastName.value, 'Last name', inputLastName.id).required('The last name is required, please check it.').isString().minLength(inputLastName.minLength)
validator.add(inputEmail.value, 'Email', 'error_email_div').required().isString().isEmail()

if(validator.hasErrors()){
    console.log(validator.getFirstError())
    // or
    console.log(validator.getErrorsMessages())
    // or
    console.log(validator.getErrorsDetail())
    // or
    document.querySelector('#div-errors').appendChild(validator.getErrorsList())
}

Methods

Note: The personalized_message parameter is to show a custom error message for each error.

| Method | Description | |-|-| | add(value: string/number/null, field_name: string, element_id: string/number/null) | Add the value to the validations | | required(personalized_message: string/null) | Check if the field value is empty or null | | isNumber(personalized_message: string/null) | Check if the field value is a number or not | | isString(personalized_message: string/null) | Check if the field value is a text or not | | isEmail(personalized_message: string/null) | Check if the field value has email format | | isTrue(personalized_message: string/null) | Check if the field value is true or not | | isFalse(personalized_message: string/null) | Check if the field value is false or not | | isNull(personalized_message: string/null) | Check if the field value is null or not | | isEmpty(personalized_message: string/null) | Check if the field value is empty or not | | max(max: number, personalized_message: string/null) | Check if the field value is less than or equal to the max value | | min(min: number, personalized_message: string/null) | Check if the field value is greater than or equal to the min value | | maxLength(max: number, personalized_message: string/null) | Check if the length of the field value is less than or equal to the max value | | minLength(min: number, personalized_message: string/null) | Check if the length of the field value is greater than or equal to the min. | | notEqual(value: string/number/null, second_field_name: string, personalized_message: string/null) | Check if the field value is not equal to the first value entered. | | hasErrors() | Check if any field has an error. Return true o false | | getErrorsMessages() | Returns errors messages in an array | | getErrorsDetail() | Returns errors in this format [... {field_name: string, error: string, message: string}] | | getErrorsList(ulAttributes: Object/null, liAtributes: Object/null | Returns errors in an HTML listing. You can indicate the attributes of the elements UL and LI through an object: {class, id, etc} |

Release Notes

v1.0.0 - Jan 04, 2024

  • Validator project uploaded

License

This library is licensed under the MIT License.