Title Validator
Validate PR title format and content
The Title Validator checks if a pull request’s title meets specified requirements, such as following a pattern, having a minimum or maximum length, or containing specific text.
Configuration
Must be set to "title"
Regex pattern(s) that the title should match
Title length constraints
Minimum title length in characters
Maximum title length in characters
Custom message to display when validation fails
Basic Usage
Examples
Conventional Commits Format
Validate that PR titles follow the Conventional Commits format:
Title Length Requirements
Ensure titles are neither too short nor too long:
Multiple Patterns
Allow multiple title formats:
Combined Requirements
Combine pattern matching and length requirements:
Pattern Matching
The Title Validator uses JavaScript regular expressions for pattern matching. When specifying patterns, remember:
- Patterns are case-sensitive by default
- Some characters need to be escaped with a backslash (
\
) - In YAML, backslashes need to be double escaped (
\\
)
For case-insensitive matching, use the i
flag: "/pattern/i"
How It Works
Retrieve PR Title
The validator retrieves the PR title from the GitHub event context
Check Pattern
If match
is specified, it checks if the title matches any of the regex patterns
Check Length
If length
is specified, it verifies the title length is within the specified range
Return Result
Returns a validation result with status (pass, fail, or error) and a message
Complete Rule Example
Best Practices
Complex regex patterns may be difficult for contributors to understand; provide clear examples