pupa 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pupa/models/base.rb +2 -5
- data/lib/pupa/refinements/json-schema.rb +3 -1
- data/lib/pupa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d431c205df726539ae647437d320f79bf4a2c6
|
4
|
+
data.tar.gz: 9a8ab849b2865d4211d86cb6b7e86fe959e8edde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c43992f870cd679e8b4ede85413d871b3018d4e30cb6d55c0e4eb208099bfadf7febaaf1a54bbedc19ea7baa470877de74516aaa49a09c738dcb8e75dce7390
|
7
|
+
data.tar.gz: f885fb7ffee30f5be495bd02cced6423494055a0b7c2a4b6ff1ca5eb8dbc97436a7d21be42039ec6d20a20e606445d1c1379b75ee5bcb31d818fbe0dd456a2bf
|
data/lib/pupa/models/base.rb
CHANGED
@@ -4,6 +4,7 @@ require 'set'
|
|
4
4
|
|
5
5
|
require 'active_support/callbacks'
|
6
6
|
require 'active_support/core_ext/hash/except'
|
7
|
+
require 'active_support/core_ext/hash/keys'
|
7
8
|
require 'active_support/core_ext/hash/slice'
|
8
9
|
require 'active_support/core_ext/object/try'
|
9
10
|
require 'json-schema'
|
@@ -150,12 +151,8 @@ module Pupa
|
|
150
151
|
# @raises [JSON::Schema::ValidationError] if the object is invalid
|
151
152
|
def validate!
|
152
153
|
if self.class.json_schema
|
153
|
-
result = {}
|
154
|
-
to_h.each do |key,value|
|
155
|
-
result[key.to_s] = value
|
156
|
-
end
|
157
154
|
# JSON::Validator#initialize_data runs fastest if given a hash.
|
158
|
-
JSON::Validator.validate!(self.class.json_schema,
|
155
|
+
JSON::Validator.validate!(self.class.json_schema, to_h.deep_stringify_keys)
|
159
156
|
end
|
160
157
|
end
|
161
158
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Pupa
|
2
2
|
class Refinements
|
3
|
-
# A refinement for JSON Schema to validate "email" and "uri" formats.
|
3
|
+
# A refinement for JSON Schema to validate "email" and "uri" formats. Using
|
4
|
+
# Ruby's refinements doesn't seem to work, possibly because `refine` can't
|
5
|
+
# be used with `prepend`.
|
4
6
|
module Format
|
5
7
|
# @see http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp/
|
6
8
|
def validate(current_schema, data, fragments, processor, validator, options = {})
|
data/lib/pupa/version.rb
CHANGED