datavalidator

module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2025 License: MIT

README ΒΆ

DataValidator

CI codecov Go Report Card Release Go Reference

A completely offline, privacy-focused data format validator for JSON, YAML, XML, and TOML files.

🌐 Try it online: https://freedatavalidator.xyz

Privacy Guarantee

πŸ”’ 100% Private & Secure:

  • ❌ No data logging, tracking, or retention
  • ❌ No network connections
  • ❌ No clipboard access
  • ❌ No telemetry or analytics
  • βœ… All validation happens locally on your machine
  • βœ… Your data never leaves your computer

Features

  • Multi-format support: JSON, YAML, XML, TOML
  • Auto-detection: Automatically detects file format
  • Batch processing: Validate multiple files or entire directories
  • CLI friendly: Supports piping and stdin input
  • Zero configuration: Works out of the box
  • Fast: Built in Go for performance
  • Cross-platform: Works on Linux, macOS, and Windows

Installation

As a Go Module
go get github.com/akhilesharora/datavalidator/pkg/validator
As a CLI Tool
go install github.com/akhilesharora/datavalidator/cmd/datavalidator@latest
Download Binary

Download the latest release from the releases page.

From Source
git clone https://github.com/akhilesharora/datavalidator
cd datavalidator
go build -o datavalidator ./cmd/datavalidator

Usage

CLI Usage
# Validate a single file
datavalidator validate config.json

# Validate multiple files
datavalidator validate config.json data.yaml settings.toml

# Validate all files in a directory
datavalidator validate ./configs/

# Pipe data through stdin
echo '{"name": "test"}' | datavalidator validate

# Specify format explicitly
datavalidator validate --format json config.txt

# Start web interface
datavalidator web --port 8080
Go Module Usage
package main

import (
    "fmt"
    "github.com/akhilesharora/datavalidator/pkg/validator"
)

func main() {
    // Validate with auto-detection
    result := validator.ValidateAuto([]byte(`{"test": true}`))
    fmt.Printf("Valid: %v, Format: %s\n", result.Valid, result.Format)
    
    // Validate with specific format
    v, _ := validator.NewValidator(validator.FormatJSON)
    result = v.ValidateString(`{"test": true}`)
    
    if !result.Valid {
        fmt.Printf("Error: %s\n", result.Error)
    }
}
Options
-f, --format string   Format to validate (json, yaml, xml, toml, auto) (default "auto")
-q, --quiet          Only show errors
-j, --json           Output results as JSON
-h, --help           Help for validate
Examples

Validate JSON file:

datavalidator validate config.json
βœ“ config.json: Valid json

Validate with errors:

datavalidator validate broken.json
βœ— broken.json: Invalid json - invalid character '}' looking for beginning of object key string

JSON output for automation:

datavalidator validate --json config.json
[
  {
    "valid": true,
    "format": "json",
    "filename": "config.json"
  }
]

Quiet mode (only errors):

datavalidator validate --quiet ./configs/
βœ— configs/broken.yaml: Invalid yaml - yaml: line 5: mapping values are not allowed in this context

Stdin validation:

curl -s https://api.example.com/data | datavalidator validate --format json

Supported Formats

Format Extensions Auto-detection
JSON .json βœ…
YAML .yaml, .yml βœ…
XML .xml βœ…
TOML .toml βœ…

Exit Codes

  • 0 - All files are valid
  • 1 - One or more files are invalid or errors occurred

Use Cases

  • CI/CD pipelines: Validate configuration files before deployment
  • Development: Check data files during development
  • Data processing: Validate input files before processing
  • Configuration management: Ensure config files are well-formed
  • API testing: Validate API responses

Privacy & Security

This tool is designed with privacy as the top priority:

  1. No network access: The binary makes zero network connections
  2. No data persistence: No temporary files, logs, or caches are created
  3. No external dependencies: All validation is done with standard libraries
  4. Memory safety: Data is processed in memory and immediately discarded
  5. Open source: Full source code available for audit

Development

Building from Source
# Clone the repository
git clone https://github.com/akhilesharora/datavalidator.git
cd datavalidator

# Install dependencies
go mod download

# Build
go build -o datavalidator ./cmd/datavalidator

# Run tests
go test ./...

# Run locally
./datavalidator web --port 8080
Project Structure
datavalidator/
β”œβ”€β”€ cmd/
β”‚   └── datavalidator/   # CLI application
β”œβ”€β”€ pkg/
β”‚   └── validator/       # Go module package
β”œβ”€β”€ web/
β”‚   └── static/          # Web interface
β”œβ”€β”€ go.mod               # Go module file
β”œβ”€β”€ go.sum               # Go dependencies
└── README.md            # This file

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Key principles:
  • πŸ”’ Maintain privacy-first approach
  • 🚫 No tracking, analytics, or data collection
  • ⚑ Keep it fast and lightweight
  • πŸ“– Document your changes

License

MIT License - see LICENSE file for details.

Author

Created by Akhilesh Arora


⭐ Star this repo if you find it useful!

Directories ΒΆ

Path Synopsis
cmd
datavalidator command
Command datavalidator provides a CLI for validating JSON, YAML, XML, and TOML files.
Command datavalidator provides a CLI for validating JSON, YAML, XML, and TOML files.
pkg
validator
Package validator provides a privacy-focused data format validation library for Go.
Package validator provides a privacy-focused data format validation library for Go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL