Registry / web-framework / react-validate-framework

react-validate-framework

JSON →
library0.15.6jsnpmunverified

React Validate Framework is a lightweight form validation utility for React applications. It enables declaration of validation schemas and custom methods, supporting both synchronous and asynchronous validation. The library utilizes the decorator pattern via `@formConnect` to integrate validation logic into class components. It also provides a set of pre-built form components (Checkbox, Radio, Select, Text, Textarea, Message) that connect to the validation system, as well as an API for manual integration with unencapsulated components. The current stable version is 0.15.6, but the package has not been updated in approximately eight years, making it incompatible with modern React versions (17+) and development practices. Its core functionality relies on older React APIs and Babel features.

web-frameworkserialization
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This is the default export, primarily used as a decorator (`@formConnect`). While technically CommonJS `require()` might work with transpilation, modern React setups predominantly use ESM imports.

import formConnect from 'react-validate-framework';

Text is a named export for a pre-built input component. Ensure it's imported using named import syntax.

import { Text } from 'react-validate-framework';

Message is a named export for displaying validation feedback. Other form components (Checkbox, Radio, Select, Textarea) are imported similarly.

import { Message } from 'react-validate-framework';

This quickstart demonstrates a basic React class component utilizing the `@formConnect` decorator to enable form validation. It shows how to define validation `schemas` and integrate pre-built form components like `Text` and `Message` to display validation status and errors. The `handleSubmit` method triggers validation and logs form values if valid.

import React from 'react'; import PropTypes from 'prop-types'; import formConnect, { Text, Message } from 'react-validate-framework'; // Note: This project is abandoned and requires React 15/16 and Babel decorator setup. // npm install react-validate-framework react@16 react-dom@16 prop-types --save // npm install @babel/plugin-proposal-decorators --save-dev // Ensure your Babel config (e.g., .babelrc) includes: // {"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]]} const schemas = { email: { rules: 'required | isEmail | maxLength(32)', messages: 'Can not be empty! | Please enter a valid email address. | Can not exceed {{param}} characters.', }, password: { rules: 'required | minLength(6)', messages: 'Password is required! | Must be at least {{param}} characters.', }, }; const methods = { // Custom methods for rules can be defined here if needed, e.g., async validation. // async validateFromServer(field, param) { /* ... */ } }; @formConnect(schemas, methods) export default class BasicForm extends React.Component { static propTypes = { formControl: PropTypes.object, }; constructor(props) { super(props); props.formControl.init({ email: '', password: '', }, { static: 'form-control', success: 'valid-success', error: 'valid-error', }); } handleSubmit = async () => { const { formControl } = this.props; if (await formControl.validate()) { console.log('Form is valid. Submitting values:', formControl.formValues); // Implement your form submission logic here } else { console.log('Form has validation errors.'); } }; render() { return ( <div className="form-group"> <label htmlFor="email">Email:</label> <Text name="email" id="email" placeholder="Please input your email" delay={100} // Debounce for asynchronous validation /> <Message className="valid-error-message" name="email" /> <label htmlFor="password">Password:</label> <Text name="password" id="password" type="password" placeholder="Please input your password" /> <Message className="valid-error-message" name="password" /> <button onClick={this.handleSubmit}>Submit</button> </div> ); } }
Debug
Known footguns
breakingThis package is incompatible with React versions 17 and 18+. It explicitly lists peer dependencies for React 15.x || 16.x, and relies on older React internal mechanisms and deprecated `ReactDOM.render` API patterns which were replaced by `createRoot` in React 18.
gotchaThe project is abandoned. The last release was approximately 8 years ago, and there are no signs of ongoing maintenance, bug fixes, security patches, or compatibility updates for newer React versions or JavaScript features.
breakingVersion 0.13.0 introduced a breaking change by altering the internal `contextTypes` mechanism to `formControl`. This impacts how form context is accessed and managed within components, requiring updates to any custom components or higher-order components that directly interacted with the form's context.
gotchaThe `@formConnect` decorator syntax requires explicit Babel configuration with `@babel/plugin-proposal-decorators` (and often `{ "legacy": true }`). This is not enabled by default in Create React App or other modern build setups without custom tooling like `react-app-rewired`.
deprecatedThe use of `contextTypes` for passing information down the component tree is a legacy React API that has been largely deprecated in favor of the Context API (`React.createContext`). While this library abstracts it, its underlying implementation uses outdated patterns.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources