File: validate.go

package info (click to toggle)
golang-github-containers-common 0.64.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,596 kB
  • sloc: makefile: 130; sh: 102
file content (18 lines) | stat: -rw-r--r-- 532 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package report

import (
	"github.com/containers/storage/pkg/regexp"
)

// Check for json, {{json }} and {{ json. }} which are not valid go template,
// {{json .}} is valid and thus not matched to let the template handle it like docker does.
var jsonRegex = regexp.Delayed(`^\s*(json|{{\s*json\.?\s*}})\s*$`)

// JSONFormat test CLI --format string to be a JSON request
//
//	if report.IsJSON(cmd.Flag("format").Value.String()) {
//	  ... process JSON and output
//	}
func IsJSON(s string) bool {
	return jsonRegex.MatchString(s)
}