Part of the AI ecosystem · 358 projects
This module uses AI to suggest field validation rules based on plain-English descriptions, allowing site builders to review and enforce them. It works on any fieldable entity, supports various AI providers, and allows for manual editing, revocation, and restoration of rules without needing to write custom code.
AI Validation Generator suggests validation rules for the fields of your content, using the AI provider your site already has, and enforces the rules you accept every time content is saved. Describe what a field should contain, review the suggestions, and keep bad data out: wrong postal codes, prices out of range, HTML in plain-text fields, duplicate values and more.
It works with any fieldable entity type: content, taxonomy terms, media, users, comments, custom blocks, paragraphs and others.
Features
- AI-suggested rules: pick an entity type and bundle, choose its fields and, optionally, describe each in plain English, for example "must be a US ZIP code". The AI suggests one or more rules per field.
- Safe by design: the AI only chooses among seven fixed rule types and fills in their settings. It never returns code, and anything outside that vocabulary, or with invalid settings such as a broken regular expression, is dropped before it is saved.
- Seven rule types:
- regular expression match;
- length in characters;
- numeric range;
- allowed values;
- no HTML markup;
- word count;
- must be unique.
- Review before saving: every suggestion has a checkbox and the message editors will see. Keep what you want and drop the rest.
- Know the impact first: each suggestion shows how many existing items would fail it, for example "3 of 128 existing entities would currently fail this rule", so a new rule never surprises you. Any saved rule set can be checked again later, with example failing values.
- Enforced everywhere: accepted rules become field validation constraints, so they apply on every edit form and to any code that validates entities. Empty optional fields are never blocked; the field's own "Required" setting decides that.
- Manual rules too: create and edit rule sets by hand, without calling the AI, and switch single rules on or off.
- Revoke and restore: turn off a whole rule set without deleting it, one at a time or in bulk, and turn it back on later.
- Clean regeneration: generating again for a field replaces its earlier AI rules instead of piling up duplicates; rules you added by hand are kept.
- Configuration: rule sets are configuration entities, deployed with configuration management like the rest of your site.
- Cost control: a per-user limit on generation requests, and a choice of provider, model, temperature and response length.
Supported field types
Field types Rule types Text (plain), Email, Telephone Regular expression, length, allowed values, no HTML, unique Text (plain, long), Text (formatted, long), Text (formatted, long, with summary) Regular expression, length, no HTML, word count Number (integer), Number (decimal), Number (float) Numeric range, allowed values, uniqueList fields are not offered: Drupal core already enforces their allowed values.
Requirements
- Drupal 10.3 or later, or Drupal 11.
- The AI module, with at least one chat provider configured, such as OpenAI or Anthropic. Requests are billed by that provider.
Installation
Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
composer require drupal/ai_validation_generator drush pm:enable ai_validation_generator
Configuration
- Set up a chat provider at Configuration » AI » AI Settings (
/admin/config/ai/settings). API keys live there, typically in the Key module; this module never stores them. - At Configuration » Development » AI Validation Generator » Settings (
/admin/config/development/ai-validation-generator/settings), choose the provider and model, the generation settings, and the number of requests a user may make per hour. - Grant the permissions:
- Generate AI Validation Rules: generate, review and save suggested rules.
- Administer AI Validation Generator: choose the provider and settings, and create, edit and delete rule sets by hand. Restrict it as you would Administer fields.
The status report warns when no chat provider is configured.
Usage
- Go to Configuration » Development » AI Validation Generator (
/admin/config/development/ai-validation-generator). - Choose an entity type and bundle, and click Load fields.
- Select the fields to validate, add a hint where it helps, and click Generate with AI.
- Review the suggested rules and their impact on existing content, uncheck what you don't want, and click Save selected rules.
- Manage the rules under Rule sets: edit, check impact, revoke, restore or delete them, or add rule sets by hand.
Support
Report bugs and request features in the issue queue.
Ask your assistant about AI Validation Generator
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- ai Drupal core
- field Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the AI ecosystem
Most installed first
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0 | Stable | 10–11 | Aug 7, 2026 |