Skip to content

validate

The config validate command checks your configuration files for errors before deployment.

Terminal window
nextdns-blocker config validate [OPTIONS]
OptionDescription
--jsonOutput in JSON format
--config-dir PATHConfig directory (default: auto-detect)
CheckDescription
JSON syntaxValid JSON format
Required fieldsDomain field present
Domain formatValid domain names
Schedule formatValid days and times
Time formatHH:MM (24-hour format)
Day namesLowercase weekday names
Unblock delayValid delay values (0, 30m, 1h, never, etc.)
No conflictsDomain not in both blocklist and allowlist
Terminal window
$ nextdns-blocker config validate
config.json: valid JSON syntax
domains configured: 5 domains
allowlist entries: 2 entries
protected domains: 1 protected
domain formats: all valid
schedules: 3 schedule(s) valid
no conflicts: no denylist/allowlist conflicts
Configuration OK
Terminal window
$ nextdns-blocker config validate
config.json: valid JSON syntax
domains configured: 5 domains
domain formats: 2 error(s)
no conflicts: 1 conflict(s)
Configuration has 3 error(s)
blocklist[2]: Invalid domain format 'not a domain'
blocklist[3]: Invalid time format '25:00' (expected HH:MM)
Domain 'example.com' appears in both blocklist and allowlist

For scripting and CI/CD pipelines, use --json for machine-readable output:

Terminal window
nextdns-blocker config validate --json
{
"valid": true,
"checks": [
{"name": "config.json", "passed": true, "detail": "valid JSON syntax"},
{"name": "domains configured", "passed": true, "detail": "5 domains"},
{"name": "domain formats", "passed": true, "detail": "all valid"},
{"name": "no conflicts", "passed": true, "detail": "no denylist/allowlist conflicts"}
],
"errors": [],
"warnings": [],
"summary": {
"domains_count": 5,
"allowlist_count": 2,
"protected_count": 1,
"schedules_count": 3
}
}
{
"valid": false,
"checks": [
{"name": "config.json", "passed": true, "detail": "valid JSON syntax"},
{"name": "domain formats", "passed": false, "detail": "2 error(s)"}
],
"errors": [
"blocklist[2]: Invalid domain format 'not a domain'",
"blocklist[3]: Invalid time format '25:00'"
],
"warnings": [],
"summary": {
"domains_count": 5,
"allowlist_count": 0,
"protected_count": 0,
"schedules_count": 2
}
}
CodeMeaning
0Configuration is valid
1Configuration has errors
blocklist[0]: Invalid domain format 'http://example.com'

Fix: Remove protocol prefix. Use example.com instead of http://example.com.

blocklist[1].schedule.monday: Invalid time format '9:00'

Fix: Use 24-hour format with leading zeros: 09:00 instead of 9:00.

blocklist[2].schedule: Unknown day name 'Mon'

Fix: Use full lowercase day names: monday instead of Mon.

Domain 'example.com' appears in both blocklist and allowlist

Fix: Remove the domain from one of the lists. A domain cannot be in both.

blocklist[3]: Invalid unblock_delay 'invalid'

Fix: Use valid formats: 0, 30m, 1h, 4h, 24h, 1d, or never.

- name: Validate config
run: |
nextdns-blocker config validate --json > validation.json
if [ $? -ne 0 ]; then
echo "Configuration validation failed"
cat validation.json
exit 1
fi
.git/hooks/pre-commit
#!/bin/bash
if [ -f "config.json" ]; then
nextdns-blocker config validate --config-dir . || exit 1
fi

Always validate before deploying configuration changes:

Terminal window
# Edit config
nextdns-blocker config edit
# Validate before sync
nextdns-blocker config validate && nextdns-blocker config push
Terminal window
# Run in CI pipeline
nextdns-blocker config validate --json | jq '.valid'

When sync isn’t working as expected:

Terminal window
# Check config first
nextdns-blocker config validate
# Then check health
nextdns-blocker health