SimpleValidations.jl

Interface for making simple validations of data
Author psrenergy
Popularity
1 Star
Updated Last
11 Months Ago
Started In
October 2023

SimpleValidations.jl

Interface for making simple validations in the database.

You use it to collect different validation errors across your application and display them in a JSON file.

Build Status Coverage
Build Status Codecov branch

Getting Started

Installation

julia> ]add https://github.com/psrenergy/SimpleValidations.jl#master

Basic Usage

using SimpleValidations

init_validations()

struct Student
    name::String
    grade::Real
    student_id::String
end

john_smith = Student("John Smith", -5.0, "1234567890")

if john_smith.grade < 0
    validation_error(
        collection = "Student",
        attribute = "Grade", 
        identifier = john_smith.student_id,
        message = "Grade cannot be negative",
    )
end

if has_validation_errors()
    dump_validation_errors("validation_errors.json")
    throw(ValidationException())
end

Used By Packages

No packages found.