Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-form-reducer-validator
Advanced tools
The validator resolver for react-from-reducer, this package uses validatorjs, and wraps it to be used with react-form-reducer
An extension package for react-form-reducer
.
The resolver wraps and uses the validatorjs
library, the library allows for a neat & simple way of adding validation rules. and the resolver allows for partial validation which is useful for stepped forms. You can also build and use your own resolver library if you like!
npm install react-form-reducer-validator
import { Resolver } from 'react-form-reducer-validator';
type MyValidatedFormType = {
name: string;
email: string;
password: string;
password_confirmation: string;
terms: boolean;
};
export function ValidatedForm() {
const {
fields,
handleInputChange,
validate,
errors
} = useForm<MyValidatedFormType>(
{
name: '',
email: '',
password: '',
password_confirmation: '',
terms: false
},
{
validation: new Resolver(
{
// Validation rules
name: 'required',
email: 'required|email',
password: 'required',
password_confirmation: 'required|same:password',
terms: 'accepted'
},
{
// Custom messages
'accepted.terms': 'Please accept the :attribute',
'same.password_confirmation': "Passwords don't match"
},
[
// Custom Validation Rules
{
name: 'telephone',
callback: (fieldValue, args, attribute, data) => {
return fieldValue.match(/^\d{3}-\d{3}-\d{4}$/);
},
message: 'The :attribute phone number is not in the format XXX-XXX-XXXX.'
}
]
)
}
);
const handleSubmit = async ()=>{
const { passed } = await validate()
if(!passed){
// throw error
}
}
}
Feedback, Issue reports, suggestions and contributions are appreciated and welcome.
FAQs
The validator resolver for react-from-reducer, this package uses validatorjs, and wraps it to be used with react-form-reducer
The npm package react-form-reducer-validator receives a total of 11 weekly downloads. As such, react-form-reducer-validator popularity was classified as not popular.
We found that react-form-reducer-validator 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.