Skip to content

psrenergy/SimpleValidations.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Interface for making simple validations of data

Resources

License

Stars

Watchers

Forks

Packages

No packages published