
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
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
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.