Lab: Apply the Polymorphic Pattern - Validator giving error

For given Lab I have created the solution

{

  "_id": "<objectId>",

  "first_name": "<string>",

  "last_name": "<string>",

  "engineer_level": "<int>",

  "education": [{

    "level": "<string>",

    "subject": "<string>"

  }],

  "years_experience": "<int>",

  "previous_employer": "<string>",

  "technical": ["<string>"],

  "non-technical": {

    "languages": ["<string>"],

    "other": ["<string>"]

  },

  "candidate_notes": "<string>",

  "recruiting_source": "<string>",

  "extend_offer": "<string>"

}

But the validator giving this error:

D:\Database\MongoDB\Course\M320>validate_m320 pattern_polymorphic --file pattern_polymorphic.json
panic: invalid character 'T' looking for beginning of value

goroutine 1 [running]:
github.com/10gen/university-courses/go/m320/common.validateSchema(0xc000055fb0, 0x8de073, 0x907, 0x966900, 0xc00003fa40, 0x1, 0x1, 0x0, 0xc000005140)
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/common/validators.go:123 +0x637
github.com/10gen/university-courses/go/m320/common.ValidateMultipleDocumentsAsStringWithMultipleSchemasAsString(0xc000055fb0, 0xc65140, 0x3, 0x3, 0xc00003fa20, 0x1, 0x1, 0x0, 0x82ab40, 0x1, ...)
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/common/validators.go:95 +0x1f4
github.com/10gen/university-courses/go/m320/common.ValidateMultipleDocumentsInFileWithMultipleSchemasAsString(0xc000055fb0, 0xc65140, 0x3, 0x3, 0xc00001c400, 0x18, 0x0, 0xc8a6b0, 0x0, 0x0)
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/common/validators.go:50 +0x7f
github.com/10gen/university-courses/go/m320/lab_pattern_polymorphic.Worker(0xc000040120, 0x2, 0x2, 0xc00001a4e0, 0x21, 0xc00001c3c0, 0x13, 0xc00001a4e0, 0x21)
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/lab_pattern_polymorphic/worker.go:39 +0x1fb
main.worker(0xc000040100, 0x4, 0x4, 0x0, 0x7e6925, 0xc00010bf88, 0xc00004a058)
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/validate_m320/main.go:67 +0x8de
main.main()
        /var/jenkins/workspace/M320 - build, test and optionally push the Go binaries/go/m320/validate_m320/main.go:40 +0x4c

Please provide solution to this.

Can you try enclosing it in an array? Try having multiple objects in the array as suggested in the lab. Let me know how it goes. :slight_smile:

Kanika

Okay I got my mistake :grimacing:

But don’t you think validator should handle this error? :thinking:

It showing such error stack as there is some loop hole in validator code which can’t handle this basic condition. :smirk:

But still thank you so much for your kind and swift response :pray: :clap: :clap: :clap:

God bless you guys :innocent:

1 Like

Sure! I would forward the concern to the team and will do our best :slight_smile:

Kanika

1 Like