Skip to content

Add equals marker and extend existing validators for cross-field validation #89

Description

@sivchari

Description

Implement cross-field validation by adding an equals marker and extending existing comparison operators to reference other fields.

Implementation Details

1. New equals marker:

type PasswordForm struct {
    // +govalid:minlength=8
    Password string
    // +govalid:equals=Password
    Confirm  string
}

2. Extend existing comparison operators:

type PriceRange struct {
    // +govalid:required
    MinPrice int
    // +govalid:gt=MinPrice  // References MinPrice field
    MaxPrice int
}

type DateRange struct {
    StartDate time.Time
    // +govalid:gte=StartDate  // References StartDate field
    EndDate   time.Time
}

Parameter interpretation:

  • Numeric values: Compare as fixed values (current behavior)
  • Identifiers: Reference fields in the same struct
  • equals marker supports all types for equality checking

Success Criteria

  • equals marker implemented
  • Existing operators support field references
  • Clear distinction between values and field references
  • Comprehensive test coverage

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions