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.

npm install react-validate-framework
INSTALL
IMPORT
SIG · REACT-VALIDATE-FRA
R
react-validate-framework
web-frameworkjavascriptv0.15.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

formConnect
import formConnect from 'react-validate-framework';
const formConnect = require('react-validate-framework');
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.
Text
import { Text } from 'react-validate-framework';
import Text from 'react-validate-framework';
Text is a named export for a pre-built input component. Ensure it's imported using named import syntax.
Message
import { Message } from 'react-validate-framework';
import * as Messages from 'react-validate-framework';
Message is a named export for displaying validation feedback. Other form components (Checkbox, Radio, Select, Textarea) are imported similarly.

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 issues
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.
fix
Consider migrating to a modern, actively maintained React form validation library. If legacy support is critical, you must use React 15 or 16 and not upgrade beyond.
affects: >=0.15.6
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.
fix
Avoid using this library for new projects. For existing projects, plan for migration to a currently maintained solution to ensure long-term stability and security.
affects: >=0.15.6
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.
fix
Ensure components accessing form context are updated to use the `formControl` property injected by the `@formConnect` decorator, as demonstrated in the README examples.
affects: >=0.13.0
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`.
fix
Configure your Babel setup (e.g., in `.babelrc` or `babel.config.js`) to include the `plugin-proposal-decorators` with the `legacy` option. For Create React App, consider using `react-app-rewired` or ejecting.
affects: *
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.
fix
No direct fix for this library's internals. This is another reason to consider migrating to a modern library that uses current React patterns.
affects: >=0.13.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'formControl')
The `@formConnect` decorator either failed to apply, or the component is not receiving `formControl` via props as expected. This can happen if Babel is not configured correctly for decorators, or if the component is mounted outside the context of `formConnect`.
fix
Verify that your Babel configuration correctly includes `@babel/plugin-proposal-decorators` (with `legacy: true`) and that the component decorated with `@formConnect` is part of a rendered tree.
Support for the experimental syntax 'decorators-legacy' isn't currently enabled
Your Babel configuration does not include the necessary plugin to parse legacy decorator syntax, or it's misconfigured.
fix
Install `@babel/plugin-proposal-decorators` and add it to your Babel configuration (e.g., `.babelrc`) with `{ "legacy": true }`. Ensure the plugin order is correct if you have other plugins like `class-properties`.
Error: ReactDOM.render is no longer supported in React 18. Use createRoot instead.
Attempting to use this library with React 18+. The library's core design and peer dependencies are tied to React 15/16, which used `ReactDOM.render` for root creation.
fix
Downgrade your React and React DOM versions to 16.x (e.g., `npm install react@16 react-dom@16 prop-types@15`). Or, if you need React 18, replace this library with a modern alternative.
ReferenceError: regeneratorRuntime is not defined
Asynchronous validation methods (`async/await`) are used, but your JavaScript environment or Babel setup does not include the `regenerator-runtime` polyfill.
fix
Install `regenerator-runtime` (`npm install regenerator-runtime`) and import it at the entry point of your application (`import 'regenerator-runtime/runtime';`) or configure Babel to include the necessary polyfills via `@babel/preset-env`.
Upgrade
Version history
0.15.6latest on npm
Audit
Dependencies
reactrequiredCore React library for UI components. Requires React 15.x or 16.x, incompatible with 17+.
react-domrequiredReact DOM rendering utilities. Requires React DOM 15.x or 16.x, incompatible with 17+.
Agent activity
10 hits · last 30 days
node
10
Resources