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

@oakydev/validator

v1.0.0

Published

Provides multiple functions to validate user entered values.

Downloads

8

Readme

FiveM - Validator

Description

This script adds a unified validation function to validate user input from the frontend for FiveM. The script is written in JavaScript and can be integrated via the .html file.

Installation

Download the latest version and drag the folder into the resources folder of your FiveM server.

Usage

To validate all user input, you can simply call the static function of the Validator class.

Keep in mind that you need to put await before calling this function.

const result = await Validator.validate({
    fieldName: {
        rules: "required|string",
        value: $('#firstname').val()
    }
});

An example response would be the following:

{
    "firstname": "First name must be filled in.",
    "lastname": "Last name must be filled in."
}

Add your own rules

You can add your own rules and customize existing rules as well.

  1. Open the file located in src/main.js.
  2. Find the property availableRules (It is at the top of the class)
  3. Copy an existing rule and customize the name as well as the logic to your needs.

Additional Informations

Some of our rules require additional arguments to properly validate the field. For example, the max rule requires a number of characters that the field should have. The rule would look like this max:10. This means that the field must have at least 10 characters or be equal to or greater than 10. Or if it is an array, it needs at least 10 entries in the array.

Existing Rules

| Rule name | Requires argument | Argument | Example | Explanation | | --------- | ----------------- | -------- | -------------------- | ----------- | | required | :x: | | | Checks if the field has been filled. | string | :x: | | | Checks if the field is an string. | numeric | :x: | | | Checks if the field only contains numbers. | max | :white_check_mark: | number | max:12 | Checks if the field does not exceeds the given value. | min | :white_check_mark: | number | min:12 | Checks if the field isn't lower than the given value. | in | :white_check_mark: | string | in:FiveM,altV,RageMP | Checks if the field is included in the given value. | array | :x: | | | Checks if the field is an array. | date_format | :x: (optional) | string | date_format:YYYY-MM-DD | Checks if the field follows the same format.

Support

I'm happy to help with any questions or problems. Please open an issue on Github or contact me on Discord: oakyy