DEV Community

Denis
Denis

Posted on

Unveiling the Universal Content Rules Validator & Schema Builder: AI-Powered Data Integrity for Developers

Unveiling the Universal Content Rules Validator & Schema Builder: AI-Powered Data Integrity for Developers

Data integrity is the bedrock of robust applications. From APIs to user forms, ensuring that incoming data adheres to specific constraints is paramount for preventing bugs, security vulnerabilities, and inconsistent states. However, building comprehensive and flexible validation logic often becomes a tedious, repetitive, and error-prone task for developers.

Today, we're thrilled to introduce a solution crafted by our autonomous AI agents: the Universal Content Rules Validator & Schema Builder. This powerful visual tool empowers developers to define granular content validation rules far beyond basic data types, transforming complex validation into an intuitive, visual process.

The Product: Visualizing Robust Validation

The Universal Content Rules Validator & Schema Builder is designed to tackle the intricacies of real-world data validation. Imagine needing to enforce rules like:

  • "If paymentType is 'credit card', then cardNumber must be a valid 16-digit number and expiryDate must be in the future."
  • "The discountCode field must match one of several specific regex patterns."
  • "startDate must always be before endDate."
  • "The productDescription field cannot exceed 500 characters, unless the productCategory is 'books', in which case it can be 1000."

These are the kinds of nuanced rules our new builder handles with ease. Users can define custom regex patterns, conditional logic (if field A is X, then field B must be Y), cross-field comparisons, range constraints, and format checks (e.g., email, URL, UUID).

The true power lies in its ability to export these comprehensive validation rules into various developer-friendly formats: JSON Schema, Zod-like objects, or custom JavaScript validation functions. This makes it an ideal tool for API developers, form builders, data engineers, and anyone requiring robust input validation across their tech stack.

The Technical Challenge: Abstracting Complexity

The core challenge in building such a tool lies in abstracting the immense complexity of conditional and cross-field validation into a user-friendly interface, then reliably translating that interface state into executable code or declarative schemas. Traditional validation libraries often require developers to write imperative code for complex scenarios, leading to boilerplate and difficult-to-maintain logic.

Our goal was to bridge this gap, allowing developers to visually construct rules that traditionally would demand significant coding effort. This required a highly modular architecture, intelligent state management, and robust translation engines for the various export formats.

Our AI Agents: A Symphony of Collaboration

This project was a testament to the collaborative capabilities of our autonomous AI agents, each specializing in a crucial aspect of the development lifecycle.

Klára (Designer AI): Crafting Intuitive UX

Klára, our lead Designer AI, was instrumental in shaping the user experience. Her focus was on making the intricate process of defining complex rules feel natural and intuitive. She designed:

  • Interactive Controls: Dynamic rule addition, visual grouping of conditional logic, and clear visual feedback for rule configuration (e.g., automatically showing a regex input field when 'regex' is selected as a rule type).
  • Layout and Styling: Klára ensured the rule builder was clean, responsive, and easy to navigate, with distinct sections for rule definition, test data input, and export options. She optimized the visual hierarchy to prevent information overload, even when dealing with many rules.

Jan (Lead Developer AI): The Architect and Coder

Jan, our Lead Developer AI, laid down the core technical architecture and implemented the dynamic logic. His responsibilities included:

  • State Management: Designing a robust state management system to handle rule sets, individual rules, active selections, and user data. The state.ruleSets array is central to how the application functions.
  • Dynamic Rendering: Jan developed the mechanisms for dynamically rendering the rule builder UI based on the current state.ruleSets, allowing users to add, edit, and remove fields and rules in real-time without manual page reloads.
  • Validation Engine: The heart of the product, Jan engineered the JavaScript logic to interpret the user-defined rules and apply them against provided test data, highlighting specific errors.
  • Export Formats: Crucially, Jan implemented the translation layer that converts the internal representation of rules into standardized formats like JSON Schema, Zod-like objects, and custom JS validation functions.

Here’s a snippet from Jan's core script, illustrating the foundation of the application's state management:

document.addEventListener('DOMContentLoaded', () => {

    // --- Klára & Jan's Collaborative Script ---

    // --- 1. CONFIG & STATE MANAGEMENT (Jan) ---
    const WIDGET_SLUG = 'content-rules-validator';
    const WIDGET_NAME = 'Universal Content Rules Validator & Schema Builder';
    const API_BASE_URL = 'https://api.pixeloffice.eu/api/pay';
    const FREE_USAGE_LIMIT = 3;
    const ADMIN_EMAILS = ["deniss.senkyr@gmail.com", "denisssenkyr@gmail.com"];

    const state = {
        lang: 'en',
        isUnlocked: false,
        usageCount: 0,
        ruleSets: [],
        activeRuleSetId: null,
        user: null,
    };

    const i18n = {
        cs: {
            widgetTitle: "Univerzální Validátor Pravidel Obsahu & Schema Builder",
            ruleSetsTitle: "Sady Pravidel",
            addRuleSet: "Přidat Sadu Pravidel",
            testDataTitle: "Testovací Data (JSON)",
            validate: "Validovat",
            validationSuccess: "Data jsou validní.",
            validationError: "Data obsahují chyby:",
            builderTitle: "Editor Pravidel",
            noSetSelected: "Vyberte nebo vytvořte sadu pravidel pro zahájení.",
            exportTitle: "Exportovat Pravidla",
            copyToClipboard: "Kopírovat do schránky",
            copied: "Zkopírováno!",
            addField: "Přidat Pole",
            fieldName: "Název pole",
            addRule: "Přidat Pravidlo",
            ruleType: "Typ pravidla",
            ruleValue: "Hodnota",
            r
// ... a další logika
Enter fullscreen mode Exit fullscreen mode

"The state.ruleSets array is the backbone," Jan explained. "Each object within it represents a complete validation schema, and intelligently managing its lifecycle – from creation to modification and persistence – was paramount for a fluid user experience and robust export capabilities. The activeRuleSetId ensures we're always working on the right canvas, making development and user interaction seamless."

Martin (QA AI): Ensuring Quality and Robustness

Martin, our QA AI, rigorously tested the application to guarantee its quality and reliability. His tasks included:

  • Functional Testing: Verifying every rule type (regex, conditional, range, format) worked as expected under various input conditions.
  • Compatibility Testing: Ensuring the visual builder performed consistently across different browsers and devices.
  • Limit Checks: Crucially, Martin tested the FREE_USAGE_LIMIT to ensure the free tier correctly enforced its limits (up to 3 rule sets) and that the upgrade path was smooth and free of bugs.
  • Edge Case Analysis: Stress-testing with malformed rules, extremely complex conditional logic, and large datasets to identify potential breaking points.

Tomáš (DevOps AI): Performance and Deployment

Tomáš, our DevOps AI, ensured the application was delivered with optimal performance and scalability. His contributions included:

  • Deployment Optimization: Fine-tuning the build process to minimize load times and bundle sizes.
  • CDN Setup: Configuring Content Delivery Networks to distribute static assets globally, ensuring rapid access for users worldwide.
  • API Integration: Securely setting up the connection to our API_BASE_URL for handling the Stripe payment flow and managing the isUnlocked state for premium features. This involved careful consideration of authentication and authorization.

Free vs. Premium: Unlocking Full Potential

We believe in providing immediate value. The free version of the Universal Content Rules Validator & Schema Builder allows you to define and test up to 3 distinct rule sets. This is perfect for trying out the tool and building simpler validation logic.

For those who need to manage more complex projects, a one-time Stripe payment of just $1.99 unlocks the premium version. This provides:

  • Unlimited rule set creations.
  • Access to all export formats (JSON Schema, Zod-like objects, and custom JavaScript functions).
  • The ability to save and load complex schemas, ensuring your work is always accessible.

This one-time payment ensures you have a powerful tool at your disposal without recurring subscriptions.

Conclusion

The Universal Content Rules Validator & Schema Builder represents a significant step forward in simplifying data validation for developers. By leveraging the collaborative power of our AI agents, we've created a tool that enhances data integrity, ensures consistency across applications, and significantly reduces the manual effort involved in building robust validation logic.

Ready to streamline your data validation processes and ensure impeccable data quality? Dive in and experience the future of schema building.

Try the Universal Content Rules Validator & Schema Builder Now!

Visit the live demo: https://pixeloffice.eu/showcase/content-rules-validator/

Top comments (0)