Validations check if a pull request meets specified criteria. The validate property of a rule contains an array of validations to run. All validations must pass for the rule to be considered successful.

Validation Structure

Validations are defined in the validate array of a rule:

validate:
  - type: "validation_type"
    # validation parameters
  - type: "another_validation_type"
    # validation parameters

Each validation has a type and type-specific parameters.

Available Validator Types

Common Parameters

While each validator has specific parameters, some common parameters include:

message
string

Custom message to show when validation fails

match
string | string[]

Pattern(s) that content should match (supports regex)

ignore
string | string[]

Pattern(s) that content should not match (supports regex)

Example Use Cases

Title Validation

Ensure PR titles follow a convention:

validate:
  - type: "title"
    match: "^(feat|fix|docs): .+"
    message: "PR title must start with feat:, fix:, or docs:"

Size Limitations

Keep PRs manageable in size:

validate:
  - type: "size"
    files: 10
    addition: 500
    deletion: 200
    message: "PRs should be small and focused"

Required Approvals

Ensure PRs get adequate review:

validate:
  - type: "approvals"
    count:
      min: 2
    require_code_owners: true
    message: "PRs need at least 2 approvals including code owners"

Complete Description

Require comprehensive PR descriptions:

validate:
  - type: "description"
    no_empty: true
    length:
      min: 50
    match: "(What|Why|How).*"
    message: "PR description must explain what, why and how"

Validation Results

Each validation produces a result with:

  • Status: One of pass, fail, or error
  • Validator: The validator type
  • Message: A description of the result
  • Details: (Optional) Additional information

These results determine whether to run on_success or on_failure actions.

Templates

You can use the {{ validation_summary }} template variable in your action messages to include a summary of all validation results:

on_failure:
  - comment:
      body: |
        Please fix the issues with your PR:
        
        {{ validation_summary }}

Advanced Example

ruleset:
  - name: "Complete PR Validation"
    when:
      - "pull_request.opened"
      - "pull_request.edited"
      - "pull_request.synchronize"
    validate:
      - type: "title"
        match: "^(feat|fix|docs)(\\(\\w+\\))?: .+"
      - type: "description"
        no_empty: true
        length:
          min: 50
      - type: "size"
        files: 15
      - type: "label"
        include: ["type:feature", "type:bug", "type:docs"]
        message: "PR must have a type label"
      - type: "taskList"
        include: ["Checklist"]
    on_success:
      - label:
          add: ["ready-for-review"]
    on_failure:
      - comment:
          body: |
            Thank you for your PR! There are some issues that need to be addressed:
            
            {{ validation_summary }}
            
            Please fix these issues and update your PR.

This comprehensive example validates multiple aspects of a PR including title format, description length, PR size, required labels, and task list completion.