
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.
react-revalidator
Advanced tools
React mixin for form validation base on revalidator.
npm install --save react-revalidator
var RevalidatorMixin = require('react-revalidator');
var UpdateStateMixin = require('react-revalidator/lib/UpdateStateMixin');
var Component = React.createClass({
mixins: [RevalidatorMixin, UpdateStateMixin],
revalidatorSchema: {
example: {
type: 'object',
required: true,
properties: {
name: {
type: 'string',
required: true,
allowEmpty: false,
minLength: 6
},
email: {
type: 'string',
required: true,
format: 'email'
}
}
}
},
getInitialState: function () {
return {
example: {}
};
},
handleNameChange: function (e) {
this.updateState({
'example.name': e.target.value
}, function () {
this.validate('example.name');
});
},
handleEmailChange: function (e) {
this.updateState({
'example.email': e.target.value
}, function () {
this.validate('example.email');
});
},
handleSubmit: function (e) {
e.preventDefault();
console.log('example: ', this.state.example);
},
handleReset: function (e) {
e.preventDefault();
this.setState({
example: {}
});
this.resetValidation();
},
render: function () {
return (
<form>
<div className={this.getFieldClass('example.name')}>
<label className='control-label'>Name</label>
<input type='text' className='form-control'
value={this.state.example.name}
onChange={this.handleNameChange}/>
{this.renderFieldMessages('example.name')}
</div>
<div className={this.getFieldClass('example.email')}>
<label className='control-label'>Email</label>
<input type='text' className='form-control'
value={this.state.example.email}
onChange={this.handleEmailChange}/>
{this.renderFieldMessages('example.email')}
</div>
<button className='btn btn-primary' onClick={this.handleSubmit}
disabled={!this.isDirty('example') || !this.isValid('example')}>
Save
</button>
<button className='btn btn-default' onClick={this.handleReset}>
Reset
</button>
</form>
);
}
});
See more revalidatorSchema infomation here.
property use object-path format.
successClass default value is has-success.
errorClass default value is has-error.
defaultClass default value is form-group.
className default value is help-block.
See example folder or demo.
FAQs
React mixin for form validation base on revalidator
The npm package react-revalidator receives a total of 5 weekly downloads. As such, react-revalidator popularity was classified as not popular.
We found that react-revalidator 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.