Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ Use the helper style already present in the package you are editing.

For rules, keep table data close to the rule test and cover both passing and
failing inputs.
Organize each rule's test declarations as one adjacent group in this order:
test-case inputs, the `Test*` function, and the `Benchmark*` function.
Finish that group before declaring the next rule's test cases.
Place shared test-case types above the rule groups and shared helpers below them.
When expected output includes validation messages, assert the exact message
unless the existing package uses a looser helper for that case.

Expand Down
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"Elts",
"Fset",
"Messagef",
"RRGGBB",
"RRGGBBAA",
"Skłodowska",
"atoi",
"cidrv",
Expand Down Expand Up @@ -70,4 +72,4 @@
"Implicits",
"mygovy"
]
}
}
44 changes: 24 additions & 20 deletions internal/messagetemplates/templatekey_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions internal/messagetemplates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const (
StringJSONTemplate
StringSemverTemplate
StringCVETemplate
StringHexColorTemplate
StringRGBTemplate
StringHSLTemplate
StringDeviceCMYKTemplate
StringContainsTemplate
StringExcludesTemplate
StringStartsWithTemplate
Expand Down Expand Up @@ -128,8 +132,15 @@ var rawMessageTemplates = map[templateKey]string{
StringJSONTemplate: "string must be a valid JSON",
StringSemverTemplate: "string must be a valid semantic version",
StringCVETemplate: "string must be a valid CVE ID",
StringContainsTemplate: `string must contain the following substrings: {{ joinSlice .ComparisonValue "'" }}`,
StringExcludesTemplate: `string must not contain any of the following substrings: {{ joinSlice .ComparisonValue "'" }}`,
StringHexColorTemplate: "string must be a valid CSS hexadecimal color",
StringRGBTemplate: "string must be a valid{{ if .Custom.LegacySyntaxOnly }} legacy comma-separated{{ end }} " +
"CSS rgb(...) or rgba(...) color",
StringHSLTemplate: "string must be a valid{{ if .Custom.LegacySyntaxOnly }} legacy comma-separated{{ end }} " +
"CSS hsl(...) or hsla(...) color",
StringDeviceCMYKTemplate: "string must be a valid{{ if .Custom.LegacySyntaxOnly }} legacy comma-separated{{ end }} " +
"CSS device-cmyk(...) color",
StringContainsTemplate: `string must contain the following substrings: {{ joinSlice .ComparisonValue "'" }}`,
StringExcludesTemplate: `string must not contain any of the following substrings: {{ joinSlice .ComparisonValue "'" }}`,
StringStartsWithTemplate: `
{{- if eq (len .ComparisonValue) 1 -}}
string must start with '{{ index .ComparisonValue 0 }}' prefix
Expand Down
4 changes: 4 additions & 0 deletions pkg/rules/error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const (
ErrorCodeStringJSON govy.ErrorCode = "string_json"
ErrorCodeStringSemver govy.ErrorCode = "string_semver"
ErrorCodeStringCVE govy.ErrorCode = "string_cve"
ErrorCodeStringHexColor govy.ErrorCode = "string_hex_color"
ErrorCodeStringRGB govy.ErrorCode = "string_rgb"
ErrorCodeStringHSL govy.ErrorCode = "string_hsl"
ErrorCodeStringDeviceCMYK govy.ErrorCode = "string_device_cmyk"
ErrorCodeStringContains govy.ErrorCode = "string_contains"
ErrorCodeStringExcludes govy.ErrorCode = "string_excludes"
ErrorCodeStringStartsWith govy.ErrorCode = "string_starts_with"
Expand Down
Loading
Loading