David warburton created AVRO-4156:
-------------------------------------
Summary: avro-js fails to validate objects union type
Key: AVRO-4156
URL: https://issues.apache.org/jira/browse/AVRO-4156
Project: Apache Avro
Issue Type: Bug
Components: javascript
Affects Versions: 1.12.0
Reporter: David warburton
When I define a record with a field that has a type that is a union then
type.isValid always returns false most of the time. Unions that include null as
a type can validate when a field has a null value, but a type like int or
string doesn't work.
{code:java}
var avro = require('avro-js');
const schema2 = {
"type": "record",
"name": "TypeUnion",
"namespace": "ex1",
"fields": [
{ "name": "optional_int", "type": ["int"] },
]};
let type = avro.parse(schema2);
const example2 = {
optional_int: 1
};
console.log(type.isValid(example2, { errorHook: console.error}));
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)