Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
js-textfield-validation
Advanced tools
An npm Package to validate textfield value.
# with npm
npm install js-textfield-validation
There are chainable and non-chainable methods.
Validation | Description | Input | Output |
---|---|---|---|
alphanumericOnly | To accept alphanumeric only. | nil | string |
dollarValue | To create a value with two decimal places. | nil | string |
ipAddress | To accept number and dot only. | nil | string |
noSpace | To remove all the spaces. | nil | string |
numOnly | To remove all the non integer. | nil | string |
removeNum | To remove all the number. | nil | string |
removeLeadingZero | To remove all the leading zero. | nil | string |
singleSpace | To accept single space between two characters only. | nil | string |
truncate | To truncate the value to a specifc length. | integer | string |
wordOnly | To remove all non alphabet. | nil | string |
Validation | Description | Input | Output | Remark |
---|---|---|---|---|
validateEmail | To check whether value is a valid email format. | nil | boolean | |
validateIPAddress | To check whether value is a valid IP address. | nil | boolean | |
validateNRIC | To check whether value is an valid NRIC in Singapore. | nil | boolean | Based on http://www.samliew.com/icval/ |
import Validation from "js-textfield-validation";
import { validateEmail, validateIPAddress, validateNRIC } from "js-textfield-validation";
import React, { Component } from "react";
import TextField from "@material-ui/core/TextField";
import Validation from "js-textfield-validation";
class App extends Component {
constructor() {
super();
this.state = {
name: "",
error: "",
};
};
handleChange = event => {
let validatedName = new Validations(event.target.value).removeNum().singleSpace();
if (validatedName.error !== "") {
this.setState({ name: validatedName.value, error: validatedName.error });
} else {
this.setState({ name: validatedName, error: "" });
}
};
render() {
return (
<div>
<TextField
id="name"
label"Name"
variant="outlined"
placeholder="Enter your name here."
value={ this.state.name }
onChange={ this.handleChange }
helperText={ this.state.error }
/>
</div>
);
};
};
import React, { Component } from "react";
import TextField from "@material-ui/core/TextField";
import Validation, { validateEmail } from "js-textfield-validation";
class App extends Component {
constructor() {
super();
this.state = {
email: "",
errorMessage: ""
};
};
handleChange = event => {
let newEmail = new Validation(event.target.value).noSpace().value;
const isValidEmail = validateEmail(newEmail);
if (isValidEmail) {
this.setState({ email: newEmail, errorMessage: "" })
} else {
this.setState({ email: newEmail, errorMessage: "Invalid email" })
}
};
render() {
return (
<div>
<TextField
id="email"
label"Email"
variant="outlined"
placeholder="Enter your email here."
value={ this.state.email }
onChange={ this.handleChange }
/>
<div>{ this.state.errorMessage }</div>
</div>
);
};
};
LICENSE.md
FAQs
An npm Package to validate textfield value.
We found that js-textfield-validation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.