caoimhebyrne / KDiscordIPC

A Kotlin library for interacting with Discord via IPC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add schema validation

caoimhebyrne opened this issue · comments

Discord has documentation on how objects should be received, which fields are optional and which aren't. For example, take the User object.

It would be nice if we could validate the incoming/outgoing objects a bit better, by ensuring that they follow a specific format (i.e. a discriminator being 4 numbers, or the details of an activity being null, or more than 2 characters.), and provide a detailed error to the user.

Something like this:

Schema validation error!

The field `details` requires the following:
- 2 or more characters of text

Object:
{ JSON Representation }

These errors would hopefully be caught in development, but a stacktrace would be provided to help with this if it for some reason occurs in production.