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 |
---|---|
julia> ]add https://github.com/psrenergy/SimpleValidations.jl#master
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