
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
passable-react
Advanced tools
Passable-React is a package that allows easy integration with passable validations. It manages the form state itself, leaving you to only care about writing the validations and hooking it all together.
When using passable-react, you let its core component PassableProvider take control over the state of the form and supply you with different functions and values that allow you connect it to your state. PassableProvider uses the children as a function pattern both for familiarity and flexibility.
npm install --save passable-react
// ./App.js
import React, {Component} from 'react';
import PassableProvider from 'passable-react';
import passes from './passes.js';
class App extends Component {
initiaFormState = {
username: 'initial value',
password: '',
spam: {
checked: true
}
}
render() {
return (
<PassableProvider passes={passes} initialFormState={this.initialFormState}>
{(setTouchedOnEvent, validateOnEvent, validateOne, validateAll, fields, errors, warnings) => {
<form name="myform" onBlur={setTouchedOnEvent} onChange={validateOne} onSubmit={validateAll}>
<input type="text" name="username" value={fields.username.value}/>
{errors[username] && <span>{fields.username.errors}</span>}
<input type="password" name="password" value={fields.password.value}/>
{errors[password] && <span>{fields.password.errors}</span>}
<input type="checkbox" name="spam" value={fields.spam.value} checked={fields.spam.checked}/>
{errors[spam] && <span>{fields.spam.errors}</span>}
<input type="submit" value="Submit"/>
</form>
}}
</PassableProvider>
);
}
}
// ./passes.js
import passable, { enforce } from 'passable';
export default function passes({ specific = [], data }) {
return passable('myform', (test) => {
test('username', 'should be a string between 3 and 10 chars', () => {
enforce(data.username.value).allOf({
largerThanOrEquals: 5,
smallerThanOrEquals: 10
});
});
test('password', 'can either be a number, or empty', () => {
enforce(data.password.value).isNotEmpty();
});
test('spam', 'must be checked', () => !!data.password.checked);
}, specific);
}
And that's all there is to it. Here is what we did:
dirty and touched.PassableProviderfields object to grab the current value and connect the inputs to the current state.What else happens here?
validateOnEvent function both validates a field, and marks it as dirty.setTouchedOnEvent marks the field as touchedHere is an example of a fields object
fields: {
checkbox: {
errors: []
value: true
warnings: []
},
radio_input: {
checked: true,
errors: [],
value: "yo",
warnings: []
},
username: {
dirty: true,
errors: Array["should be a string between 3 and 10 chars"],
hasError: true,
hasWarning: false,
touched: true,
value: "An",
warnings: []
}
}
The errors and warnings objects are simply counters of the amount of errors in each field, saving you the hassle of traversing down the fields object and counting each field manually:
errors: {
phone: 1
username: 1
}
FAQs
Wrapper Component for react that allows easy Passable integration
We found that passable-react 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.