Skip to content

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

License

Notifications You must be signed in to change notification settings

twocity/NonNullValidator

Repository files navigation

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages