aboutsummaryrefslogtreecommitdiff
path: root/validators/bash/README.md
blob: 3692a1d7950bde5c072ae49706026be27a3c634a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Bash Validator

A Bash script for validating `.gitinfo` files.

## Requirements

- Bash 4+
- [jq](https://jqlang.github.io/jq/) (JSON processor)

Install jq:

```bash
# Debian/Ubuntu
apt install jq

# macOS
brew install jq

# Windows (via Chocolatey)
choco install jq
```

## Usage

```bash
# Make executable (first time only)
chmod +x validate.sh

# Validate .gitinfo in current directory
./validate.sh

# Validate a specific file
./validate.sh path/to/.gitinfo
```

## Features

- Parses JSONC (strips `//` and `/* */` comments)
- Validates against the gitinfo JSON Schema
- Checks types and formats (URI, email)
- Enforces `additionalProperties: false`
- Returns exit code 0 on success, 1 on failure
- Color-coded output (green for success, red for errors)

## Example Output

```
✓ .gitinfo is valid
```

```
Validation failed for .gitinfo:
  - .root: invalid URI "not-a-url"
  - root: unknown property "invalid_field"
```

## Limitations

- Comment stripping is simplified and may not handle edge cases with comments inside strings
- For complex validation, consider using the Node.js validator