Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.35 KB

README.md

File metadata and controls

53 lines (38 loc) · 1.35 KB

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