twocity / NonNullValidator

Validate class's non-null property after Gson's deserialization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NonNullValidate

Validate class's non-null property after Gson's deserialization.

Usage

Use NonNullValidate to annotate your class:

@NonNullValidate
data class Repo(val name: String,
	val description: String)

Name of your TypeAdapterFactory:

kapt {
  arguments {
    arg("nonNullValidator.factoryName", "example.GsonNonNullValidator")
  }
}
val gson = GsonBuilder().registerTypeAdapterFactory(GsonNonNullValidator()).create()
// this will throw JsonSyntaxException, since `description` is absent
val repo = gson.fromJson("""{"name":"NonNullValidate"}""", Repo::class.java)

Motivation

TODO

Download

TODO

Licence

MIT

About

Validate class's non-null property after Gson's deserialization.

License:MIT License


Languages

Language:Kotlin 100.0%