Sha256: 6480eed8ebf86799b413f32d5b06a0491e537dcd1034f1a4cc4ea8131948ba8d
Contents?: true
Size: 659 Bytes
Versions: 2
Compression:
Stored size: 659 Bytes
Contents
require 'contracts' require 'json' module Fuselage module Support # Payload validation for Resource module Validation include ::Contracts::Core include ::Contracts::Builtin Contract None => String def validated(payload) return payload unless malformed? payload STDERR.puts 'Resource failed to produce valid JSON', payload abort end Contract None => Bool def valid?(payload) JSON.parse payload true rescue JSON::ParseError false end Contract None => Bool def malformed?(payload) !valid? payload end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
concourse-fuselage-0.5.1 | lib/concourse-fuselage/support/validation.rb |
concourse-fuselage-0.5.0 | lib/concourse-fuselage/support/validation.rb |