Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 693 Bytes

File metadata and controls

41 lines (28 loc) · 693 Bytes

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