Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema validation at the time of encoding #208

Open
hassan-sahi opened this issue Jun 8, 2022 · 2 comments
Open

schema validation at the time of encoding #208

hassan-sahi opened this issue Jun 8, 2022 · 2 comments

Comments

@hassan-sahi
Copy link

Hi,

We followed the example and created schema as

const schema = `
{
"type": "record",
"name": "RandomTest",
"namespace": "examples",
"fields": [{ "type": "string", "name": "fullName" }]
}

Successfully encoded and decoded data. However, just to see if the validation is working, we
created data like {fullName: "ABC", dept: "CS", age: 24} ... we expected it to give error when encoding this data.
But it encoded the data and when we decoded we got fullName field ... not the two other data fields.

How can we enforce it to give error that this data is not as per the schema created above and has new data fields?

Thanks a lot !

@lmeadors
Copy link

lmeadors commented Dec 19, 2022

I just hit this, too. The validation is kind of half-baked.

If I send an invalid value for an enum, it catches that.
If I omit a required field, it catches that.
If I send the wrong type for a field, it catches that.
If I have a typo in an optional field's name, it silently discards it and keeps walking. 😞

Thank you and have a great rest of your day!

@Javarria
Copy link

Did you guys ever figure it out im trying to do the same thing and I don't see anything online lol. I want to take the messages that don't follow the schema and put them into a dead message queue that I created .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants