Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 756 Bytes

README.md

File metadata and controls

39 lines (29 loc) · 756 Bytes

kvalidator

Why use kvalidator?

  • Works anywhere and everywhere. [llvn\native, browser, jvm, android, etc]
  • Readable and declarative validation rules.
  • Error messages with multilingual support.

Installation

repositories {
    jcenter()
}

dependencies {
    implementation("com.github.marifeta:kvalidator:0.0.1")
}

Usage

val rules = mapOf<String, List<Rule>>(
        "one_number" to listOf(Between(5, 30)),
        "one_string" to listOf(Between(3, 7))
)

val validator = Validator(somethingKotlinJsonData, rules)        

if(!validator.validate()) {
    validator.errors.forEach {(attribute, messages)->
        messages.forEach { msg ->
            println("Error: $attribute has error by $msg")
        }
    }
}