[
https://issues.apache.org/jira/browse/AVRO-4156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David warburton resolved AVRO-4156.
-----------------------------------
Resolution: Not A Problem
Sorry, this is the intended behavior. If you want the union to match you need
to put \{int: 1} instead of just the literal 1.
> 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
> Priority: Minor
>
> 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)