You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

notesgen-validation

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notesgen-validation

All type of form validations on a website

1.1.7
latest
Source
npm
Version published
Weekly downloads
1
-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

Notesgen Form Helper

this package contain all type of validations

Github Url

https://github.com/Aabir1/notesgen-forms-validation

Installation

npm i notesgen-validation

Usage


import NotesgenValidation from 'notesgen-validation';

// simple usage
const result = NotesgenValidation.isNumber(123123);

// use this function to validate the complete form.
validate = () => {
    let errors = {}
    let isValid = true;

    if (NotesgenValidation.isEmpty(this.state.model.link)) {
        errors.link = "link field cannot be empty."
        isValid = false
    } else if (!NotesgenValidation.isUrl(this.state.model.link)) {
        errors.link = "Please enter valid url."
        isValid = false
    }

    if (NotesgenValidation.isEmpty(this.state.model.title)) {
        errors.title = "Title field cannot be empty."
        isValid = false
    } else if (NotesgenValidation.isNumber(this.state.model.title)) {
        errors.title = "Numbers are not allowed in title field."
        isValid = false
    }

    if (!NotesgenValidation.isFile(file)) {
        errors.image = 'Please select valid image.';
        result = false;
    } else if (!NotesgenValidation.isValidFileSize(file)) {
        errors.image = 'Image should not be greater than 2MB.';
        result = false;
    }

    this.setState({ errors: errors })
    return isValid;
}

submitForm = async () => {
    if (this.validate()) {
        // you api call
        //whatever you wanna do after validation
    }
}

About Us

It is a basic validator if any validator is missing, please raise an issue at https://github.com/Aabir1/notesgen-forms-validation/issues.

Keywords

validations

FAQs

Package last updated on 15 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts