golden_fleece 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dadad30183120be89348ef186c0be8de8d1cf6e
|
4
|
+
data.tar.gz: 13e14e0c497115e0e7dff33822b2864efd0bb7c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5b3b5e14665764464cbf89ba630db8c549463572696dc98de7a31a607549426d0d9cc821f06838850313aec07f4f5fcdbaa37cb05acff66544b01638f66fc03
|
7
|
+
data.tar.gz: 7c115cdb975db18cda2b27aca36329e2c7d23e3ac0c160601e922e18f50a9bb348cdc8df721efbeef5071ff19172889c6f7f8529a9e84b9379307d7493fe35ae
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
### [0.1.2] - 2015-05-26
|
9
|
+
### Changed
|
10
|
+
- Allow redefining individual schemas
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Validation no longer stops after encountering a single invalid key in a hash
|
8
14
|
|
9
15
|
## [0.1.1] - 2017-05-25
|
10
16
|
### Fixed
|
@@ -20,5 +26,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
20
26
|
- Getters
|
21
27
|
- Specs
|
22
28
|
|
23
|
-
[Unreleased]: https://github.com/earksiinni/golden_fleece/compare/v0.1.
|
24
|
-
[0.1.
|
29
|
+
[Unreleased]: https://github.com/earksiinni/golden_fleece/compare/v0.1.2...HEAD
|
30
|
+
[0.1.2]: https://github.com/earksiinni/golden_fleece/compare/v0.1.1...v0.1.2
|
31
|
+
[0.1.1]: https://github.com/earksiinni/golden_fleece/compare/v0.1.0...v0.1.1
|
@@ -2,8 +2,18 @@ module GoldenFleece
|
|
2
2
|
class Context
|
3
3
|
module Schemas
|
4
4
|
def define_schemas(attribute, schema_definitions = {})
|
5
|
-
schemas[attribute.to_sym]
|
6
|
-
|
5
|
+
attribute_schema = schemas[attribute.to_sym]
|
6
|
+
|
7
|
+
# Allow redefining individual schemas
|
8
|
+
if attribute_schema
|
9
|
+
schema_definitions.each do |schema_name, schema_definition|
|
10
|
+
schemas[attribute.to_sym][schema_name.to_sym] = schema_definition
|
11
|
+
end
|
12
|
+
else
|
13
|
+
schemas[attribute.to_sym] = schema_definitions
|
14
|
+
end
|
15
|
+
|
16
|
+
attributes << attribute unless attributes.include? attribute
|
7
17
|
end
|
8
18
|
end
|
9
19
|
end
|
@@ -29,10 +29,7 @@ module GoldenFleece
|
|
29
29
|
validatable_keys.each do |key|
|
30
30
|
path = build_json_path(parent_path, key)
|
31
31
|
|
32
|
-
validate_key key, path
|
33
|
-
|
34
|
-
# If all keys on our current level are valid, proceed
|
35
|
-
if errors.empty?
|
32
|
+
if validate_key key, path
|
36
33
|
schema = schemas[key]
|
37
34
|
value = schema.value.compute(record)
|
38
35
|
|
@@ -52,7 +49,12 @@ module GoldenFleece
|
|
52
49
|
attr_reader :persisted_json, :schemas, :parent_path, :validatable_keys, :record, :attribute, :errors
|
53
50
|
|
54
51
|
def validate_key(key, path)
|
55
|
-
|
52
|
+
if schemas.keys.include? key
|
53
|
+
true
|
54
|
+
else
|
55
|
+
errors << "Invalid key #{error_suffix(attribute, path)}"
|
56
|
+
false
|
57
|
+
end
|
56
58
|
end
|
57
59
|
|
58
60
|
def validate_type(value, valid_types, path)
|
data/lib/golden_fleece/value.rb
CHANGED