New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

form-part-validator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-part-validator

The validator allows you to specify easily what each input should contain to be valid you can then watch for errors :

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

FORM PART VALIDATOR

The validator allows you to specify easily what each input should contain to be valid you can then watch for errors :

import Validator from "./validator.js";

const validator = new Validator();
validator.watch(document.querySelectorAll("input"));

you simply add a keyword to it's data-form-constraints attribute, separated by spaces :

<input type="text" name="foo" data-form-constraints="length:0:38 nodot nowhitespace nonumber">

this will, when using the watch function, produce an error badge when the input doesn't match it's constraints

CONSTRAINTS

namefunctionusage
lengthassert length between min and maxlength:min:max
minLengthassert minimum lengthminLength:min
maxLengthassert maximum lengthmaxLength:max
textassert value contains some texttext
uppercaseassert value is uppercaseuppercase
lowercaseassert value is lowercaselowercase
numberassert value is numbersnumber
nodotassert value has not dotsnodot
nowhitespaceassert value whitspacenowhitespace
nonumberassert value contains no numbersnonumber
emailassert value looks like an emailemail
dateInPastassert the date is x years:months:days in the pastdateInPast:year:month:day
dateInFutureassert the date is x years:months:days in the futuredateInPast:year:month:day

MUST HAVE

the name attribute is necessary for error messages to work properly

FAQs

Package last updated on 23 Jan 2023

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