halidator icon indicating copy to clipboard operation
halidator copied to clipboard

Getting "_links does not exist" when no _links are returned

Open kleinjm opened this issue 7 years ago • 1 comments

According to the hal spec, _links are optional

Please let me know if this is expected behavior. If so, I'm afraid I can't use this gem.

kleinjm avatar Mar 27 '18 18:03 kleinjm

True it's not part of the spec but IMHO you just have regular json and don't need HAL specific validation if there's no _links attribute.

From the readme https://github.com/deathbob/halidator

The default validator is a pure ruby implementation that is slightly more strict than the spec http://tools.ietf.org/html/draft-kelly-json-hal-03. (Specifically, the default validator requires you to have a self link ...

You can try the json-schema validator built in, that might pass where the default hal validator fails

puts "Valid = #{Halidator.new(string, :json_schema).valid?}"
puts "Valid = #{Halidator.new(json, :json_schema).valid?}"

deathbob avatar Mar 27 '18 19:03 deathbob