VUT is a next-generation all-in-one framework for data validation, assertion, and unit testing in Vlang.
Inspired by the best of Zod, Jest, PestPHP, and Laravel Validation, it brings a modern, elegant, and powerful developer experience β all in native V π
- π§ Validation Engine β Type-safe, chainable, expressive (
string().email().min(3)) - βοΈ Unit Testing β
describe,it,test.each,expect& matchers - π Rich Reporters β Console, JSON & TAP with beautiful colors and emojis
- π§© Schema-based Validation β Compose complex structures like Zod or Vine
- π§ͺ Spies & Mocks β Observe function calls, arguments & results
- π¦ Tree View β Hierarchical test runner with β β βͺ indicators
- π Async & Timeout support (future-proof for coroutines)
v install siguici.vutmkdir -p ${VMODULES:-$HOME/.vmodules}/siguici
git clone --depth=1 https://github.com/siguici/vut ${VMODULES:-$HOME/.vmodules}/siguici/vutModule {
dependencies: [
'siguici.vut'
]
}import vut { filter }
assert filter(true).is_bool()
assert filter(true).is_true()
assert filter(2).is_any_int()
assert filter(5.4).is_any_float()
assert filter(8).is_num() // int or floatimport vut { ensure }
t := true
ensure(t).is_bool().is_true()import vut { expect }
t := true
expect(t).to_be_bool().to_be_true()import vut { string, number, boolean }
name_schema := string().required().min(3).max(50)
email_schema := string().email()
age_schema := number().integer().min(18)
consent_schema := boolean()
// β
Validate values
name := 'John Doe'
email := '[email protected]'
age := 25
consent := true
println(name_schema.validate(name, 'name')) // -> ok: true
println(email_schema.validate(email, 'email'))
println(age_schema.validate(age, 'age'))
println(consent_schema.validate(consent, 'consent'))import vut { Schema, string, number }
struct User {
name string
email string
age int
}
user_schema := Schema[User]{
fields: {
'name': string().min(3).max(50)
'email': string().email()
'age': number().integer().min(18)
}
}
result := user_schema.validate({
name: 'Alice',
email: '[email protected]',
age: 22
})
if result.ok {
println('β
Validation passed!')
} else {
for err in result.errors {
println('β ${err.path}: ${err.message}')
}
}import vut { describe, it, expect }
describe('Math utilities π³') {
it('adds numbers correctly') {
expect(2 + 2).to_equal(4)
}
it('handles floats precisely') {
expect(0.1 + 0.2).to_be_close_to(0.3, 0.001)
}
it('is skipped for now').skip()
it('is planned later').todo()
}describe('User module') {
describe('Validation') {
it('accepts valid email') {
expect('[email protected]').to_match(r'.+@.+')
}
}
describe('Authentication') {
it('should login successfully') {
expect(true).to_be_true()
}
}
}| Matcher | Description |
|---|---|
.to_equal(expected) |
Deep equality check |
.to_be_true() / .to_be_false() |
Boolean checks |
.to_be_greater_than(n) / .to_be_less_than(n) |
Numeric comparison |
.to_contain(sub) |
String / Array containment |
.to_match(regex) |
Regex pattern match |
.to_throw() |
Expects a panic or error |
.to_be_close_to(value, delta) |
Floating-point precision match |
.to_pass(schema) |
Passes validation schema |
import vut { spy }
mut fn add(a int, b int) int {
return a + b
}
mut s := spy(add)
s.call(2, 3)
s.call(1, 4)
expect(s.call_count).to_equal(2)
expect(s.called_with(1, 4)).to_be_true()
expect(s.returned(5)).to_be_true()import vut { test }
test.each([
[2, 3, 5],
[10, 5, 15],
])('adds numbers correctly') { a, b, expected ->
expect(a + b).to_equal(expected)
}VUT supports multiple output styles for your tests and CI pipelines:
| Reporter | Description |
|---|---|
| π₯ Console | Pretty tree view with colors & emojis |
| π JSON | Structured JSON for CI tools |
| π§± TAP | Test Anything Protocol output |
Example output in console:
π³ VUT Test Suite
βββ User module
β βββ Validation
β β β
accepts valid email
β βββ Authentication
β βͺ should login successfully (skipped)
βββ Math utilities
β adds numbers correctly
π‘ is planned later (todo)
Summary: β
3 passed | β 1 failed | βͺ 1 skipped | π‘ 1 todo
| Symbol | Meaning |
|---|---|
| β | Passed |
| β | Failed |
| βͺ | Skipped |
| π‘ | Todo |
VUT = Validation + Utility + Test
A single framework that unifies validation and unit testing with the same philosophy:
- Intuitive
- Fluent
- Expressive
- Fully native to V
- Async test support
- File-based test discovery
- Plugin system (custom matchers & reporters)
- Schema-based transformations
- Integration with
v fmtandv test
MIT Β© Sigui KessΓ© Emmanuel
- π GitHub: github.com/siguici/vut
- π¬ Discussions: GitHub Discussions
- π‘ Issues & Suggestions: Submit an Issue
Made with β€οΈ by Sigui KessΓ© Emmanuel For the next generation of Vlang developers βοΈπ