title: Avro genericdata.Record ignores data types
body: <p>I have the following avro schema</p>
  
  <pre><code>{ "namespace": "example.avro",
    "type": "record",
    "name": "User",
    "fields": [
              {"name": "name", "type": "string"},
              {"name": "favorite_number",  "type": ["int", "null"]},
              {"name": "favorite_color", "type": ["string", "null"]}
              ]
   }
  </code></pre>
  
  <p>I use the following snippet to set up a Record</p>
  
  <pre><code>val schema = new Schema.Parser().parse(new File("data/user.avsc"))
  val user1 = new GenericData.Record(schema)  //strangely this schema only checks for valid fields NOT types.
  user1.put("name", "Fred")
  user1.put("favorite_number", "Jones")
  </code></pre>
  
  <p>I would have thought that this would fail to validate against the schema</p>
  
  <p>When I add the line</p>
  
  <pre><code>user1.put("last_name", 100)
  </code></pre>
  
  <p>It generates a run time error, which is what I would expect in the first case as well.</p>
  
  <blockquote>
    <p>Exception in thread "main" org.apache.avro.AvroRuntimeException: Not a valid schema field: last_name
      at org.apache.avro.generic.GenericData$Record.put(GenericData.java:125)
      at csv2avro$.main(csv2avro.scala:40)
      at csv2avro.main(csv2avro.scala)</p>
  </blockquote>
  
  <p>What's going on here?</p>