@validation-rules-engine/core
v1.0.0
Published
Framework-independent core for Validation Rules Engine (VRE)
Maintainers
Readme
Validation Rules Engine Core
@validation-rules-engine/core is the framework-independent core of Validation Rules Engine (VRE). It contains validation contracts, fluent validators, built-in rules, results, and model-state utilities without importing Angular or another UI framework.
Installation
npm install @validation-rules-engine/core underscoreunderscore is a peer dependency retained for validator compatibility.
Capabilities
- Define reusable policies with
ValidationPolicy - Build field validators with
ValidatorHelper - Apply built-in rules through
ValidationHelper - Represent field, required, form-group, and policy-group results
- Track touched fields and determine when errors should be visible
- Reset validation metadata and identify validation-failure shapes
Example
import {
ValidationPolicy,
Validator,
ValidatorHelper
} from '@validation-rules-engine/core';
export class AccountPolicy implements ValidationPolicy {
addValidations(v: ValidatorHelper): Validator[] {
return [
v.validateFor('email')
.isRequired('Email is required')
.isEmail('Enter a valid email address')
];
}
}Public API
ValidationPolicy,ValidationModelValidator,ValidatorHelper,ValidationHelperValidationError,ValidationResult, andRequiredResultFormGroupStatus,PolicyGroupConfig, andControlType- validation metadata, touched-state, reset, and failure-shape utilities
The Angular expression-based policy executor remains in @validation-rules-engine/angular because it relies on Angular's expression parser. Extracting it requires a separately tested parser abstraction.
Architecture
Core is the lowest-level package. Framework adapters may depend on it; it never depends on an adapter. The repository enforces this rule with npm run architecture:verify.
License
MIT - see LICENSE.
