question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating with named schemas

See original GitHub issue

After the change from using a global schema map to passing around named schemas It seems to me that validating a message against a complex schema with nested named schemas is not possible (or I have just missed it). Previously I would use fastavro.validation.validate to validate the a message against a schema. However that fails without the global variable. However using the private API function fastavro.validation._validate passing in the datum, schema and my named schemas works.

I don’t feel comfortable to simply use the private API, although it works at the moment. Would you consider introducing a function to the public API that wraps the private function, or add named_schemas as a keyword only argument to fastavro.validation.validate?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scottbeldencommented, Jan 21, 2021

I went ahead and merged this. It seems like it’s in a useable state and I’d rather go ahead and get it out there for people to use if they’d like to.

0reactions
scottbeldencommented, Jan 21, 2021

That’s a good observation, but I think that’s okay. The two ways around that that I can think of would be the following:

  1. Have some global state to know previous schemas that have been loaded. This is what used to be done with SCHEMA_DEFS and was removed because it would cause non-obvious errors
  2. Allow the user to pass the named_schemas structure (which is basically the local version of SCHEMA_DEFS) into some of these functions since that structure has the knowledge of previous parsed schemas. At the moment though I’m not a fan of users having to really interact with that structure as it feels like it would make for an ugly and unintuitive API.

So for the moment I think being more explicit about the schema dependencies is okay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema Validation
If the Enterprise Gateway receives a message with an improperly formed <name> element, it will reject the message. The Schema Validation filter can...
Read more >
Schema Validation on Confluent Server
Schema Validation enables the broker to verify that data produced to a Kafka topic is using a valid schema ID in Schema Registry...
Read more >
How To Use Schema Validation in MongoDB
MongoDB has a feature called schema validation that allows you to apply constraints on your documents' structure. Schema validation is built ...
Read more >
6. Schemas & Validation
Assigning types to a property enables certain validation keywords to be used for the property. For example, if a name property has a...
Read more >
A Vocabulary for Structural Validation of JSON
JSON Schema (application/schema+json) has several purposes, one of which is JSON instance validation. This document specifies a vocabulary for JSON Schema ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found