UNPKG

type-compiler

Version:

A TypeScript compiler plugin for enhanced runtime type checking and analysis with Zod validation

107 lines (75 loc) 4.7 kB
# Pattern-Based Field Matching Documentation Welcome to the comprehensive documentation for the pattern-based field matching feature in the type-compiler plugin. This collection of guides will help you understand, implement, and get the most out of this powerful feature. ## Overview Pattern-based field matching allows you to apply consistent validation rules to fields with similar names across your entire codebase. By defining regex patterns that match field names, you can ensure that all related fields use the same validation logic, regardless of where they appear in your types. ## Documentation Guides ### [Special Field Validators](/docs/special-field-validators.md) The foundational guide that explains the concept of special field validators, how to configure them, and common use cases. This guide covers: - Basic configuration in `tsconfig.json` - How special field validators work - Common validators for different field types - Advanced usage and limitations ### [Contextual Validators](/docs/contextual-validators.md) A guide to using context-specific validation rules based on parent type names. This guide covers: - Applying different validation to the same field name in different types - Pattern-based type matching - Combining contextual and special field validators - Priority rules for validator selection - Real-world examples and use cases ### [Custom Error Messages](/docs/custom-error-messages.md) A complete guide to configuring and using custom error messages for validation. This guide covers: - Adding custom error messages to field validators - Context-specific error messages - Pattern-based error messages - Priority order for validation messages - Runtime usage with Zod schemas - Best practices for writing helpful error messages ### [Pattern Matching Visuals](/docs/pattern-matching-visuals.md) A visual guide that explains the pattern matching process with diagrams and flowcharts. This guide includes: - Flowcharts of the matching process - Diagrams showing matching priority - Visual examples of pattern matching - Field name analysis with visual breakdowns - Comparative benefits visualization ### [Pattern Matching Implementation](/docs/pattern-matching-implementation.md) A detailed guide on implementing pattern-based field matching in your project. This guide covers: - Configuration structure - Implementation steps - Compilation process visualization - Generated schema examples - Visual comparison of before and after implementation - Code examples - Best practices ### [Regex Pattern Guide](/docs/regex-pattern-guide.md) A beginner-friendly guide to understanding the regex patterns used in field validation. This guide includes: - Understanding regex basics - Common regex symbols - Visual breakdowns of common patterns - Building your own patterns - Pattern testing visualization - Common regex patterns cheat sheet - Debugging tips ### [Pattern Matching Examples](/docs/pattern-matching-examples.md) Real-world examples of pattern-based field matching across different domains. This guide showcases: - E-commerce product catalog example - User authentication system example - Financial transactions example - Analytics dashboard data example - Cross-domain pattern matches - Performance impact analysis ## Getting Started If you're new to pattern-based field matching, we recommend following this reading order: 1. [Special Field Validators](/docs/special-field-validators.md) - Understand the basics 2. [Pattern Matching Visuals](/docs/pattern-matching-visuals.md) - See how it works 3. [Regex Pattern Guide](/docs/regex-pattern-guide.md) - Learn the pattern syntax 4. [Custom Error Messages](/docs/custom-error-messages.md) - Improve validation feedback 5. [Pattern Matching Implementation](/docs/pattern-matching-implementation.md) - Implement in your project 6. [Pattern Matching Examples](/docs/pattern-matching-examples.md) - See real-world applications ## Additional Resources - [Special Validators Example](/examples/special-validators) - A complete example project demonstrating pattern-based field matching - [Contextual Validators Example](/examples/contextual-validators) - An example showing context-specific validation rules - [Custom Error Messages Example](/examples/custom-error-messages) - An example demonstrating custom validation error messages - [IDE Suggestions Example](/examples/ide-suggestions) - An example showing IDE integration features - [Type Compiler README](/README.md) - General information about the type-compiler plugin ## Contributing Contributions to this documentation are welcome! Please feel free to submit pull requests with improvements, corrections, or additional examples.