code: public static void checkTypeConsistency(Schema schema,
                                            PartitionStrategy strategy,
                                            String fieldName, Object... values) {
      Schema fieldSchema = fieldSchema(schema, strategy, fieldName);
  
      for (Object value : values) {
        // SpecificData#validate checks consistency for generic, reflect,
        // and specific models.
        Preconditions.checkArgument(
            SpecificData.get().validate(fieldSchema, value),
            "Value '%s' of type '%s' inconsistent with field schema %s.",
            value, value.getClass(), fieldSchema);
      }
    }
docs: Checks that the type of each of {@code values} is consistent with the type of
  field {@code fieldName} declared in the Avro schema (from {@code descriptor}).