Skip to content

Simplify Validator interface with centralized field handlingΒ #85

@sivchari

Description

@sivchari

Description

Refactor the Validator interface to eliminate redundancy and centralize field information handling.

Implementation Details

New interface design:

type Validator interface {
    Validate(field *FieldInfo) ValidationCheck
}

type FieldInfo struct {
    Name       string
    Type       types.Type
    StructName string
    Path       string
}

type ValidationCheck struct {
    Condition string   // "len(t.Name) == 0"
    ErrorType string   // "required"
    Reason    string   // "field is required"
    Imports   []string // ["unicode/utf8"]
}

Benefits:

  • Validators no longer duplicate field information
  • Error generation logic is centralized
  • Easier to implement new validators

Success Criteria

  • All existing validators migrated to new interface
  • Reduced code duplication
  • Simplified validator implementations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions