schema-resume-validator 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d785a0e550c5e5eb9d7ab2bbb6e7d0977dfab6dcee108d6b934f2e0de3754b2
4
- data.tar.gz: c5b97fc92f8a9aa8c9a4c8a5846e74018d946273263b65abafed1bdb76e8ff00
3
+ metadata.gz: 2c8f037d3794ca4ad5a0c1ba8daebc85795b6986656854cccc77311354f8ce10
4
+ data.tar.gz: 1427b6db1c8c1cf0deeb59762ecf06660f1b90ee6c18df72e57fb0ec4aeb3893
5
5
  SHA512:
6
- metadata.gz: 9e36c63753da817fd4a629e34caf08820ed60201854aa9f97c8b21f85d8b8b6db021db533d880f7cc88fffdcfd26980a0fa4262ef2ff0eef07f2f85bf9e53fcb
7
- data.tar.gz: cef33601db4d1b1f3ad9b993dc0c8eab890daeff126a1c24a2601dc41a8038b93471d578c743f68d5efffc17d59b92cb16e623fd41ee4958cf8b2ebda3a6af48
6
+ metadata.gz: 5d08ea5502f28e179643697aa1a43993ae5aee054bbddd1d3ced30b10002ea61d5eeb34049c6f6d4a89627729a7ff18bd0a9c5c75dba81da48e4dd644745437e
7
+ data.tar.gz: 70101bd1346a1487ee72361837f02afa1864eb6066b57dd2b2c33153be01320b359b72cd99e4dc8ec46b89562ccf7d83a06fb20beb360f1bfe0b8c6cd03492a9
@@ -0,0 +1,102 @@
1
+ require 'json'
2
+ require 'json-schema'
3
+
4
+ module SchemaResume
5
+ class Validator
6
+ attr_reader :schema, :meta_schema, :context
7
+
8
+ def initialize(schema_path: nil)
9
+ @schemas_dir = File.join(File.dirname(__FILE__), '../../schemas')
10
+
11
+ if schema_path
12
+ @schema = load_json(schema_path)
13
+ else
14
+ @schema = load_json(File.join(@schemas_dir, 'schema.json'))
15
+ end
16
+
17
+ @meta_schema = load_json(File.join(@schemas_dir, 'meta-schema.json'))
18
+ @context = load_json(File.join(@schemas_dir, 'context.jsonld'))
19
+ end
20
+
21
+ # Validate a resume document
22
+ #
23
+ # @param resume [Hash, String] Resume data as hash or JSON string
24
+ # @return [Hash] Validation result with :valid and :errors keys
25
+ def validate(resume)
26
+ resume_data = parse_resume(resume)
27
+
28
+ errors = JSON::Validator.fully_validate(
29
+ validation_schema,
30
+ resume_data,
31
+ errors_as_objects: true,
32
+ version: :draft6
33
+ )
34
+
35
+ {
36
+ valid: errors.empty?,
37
+ errors: errors.map { |error| format_error(error) }
38
+ }
39
+ end
40
+
41
+ # Get the JSON Schema
42
+ #
43
+ # @return [Hash] The schema
44
+ def get_schema
45
+ @schema
46
+ end
47
+
48
+ # Get the meta-schema
49
+ #
50
+ # @return [Hash] The meta-schema
51
+ def get_meta_schema
52
+ @meta_schema
53
+ end
54
+
55
+ # Get the JSON-LD context
56
+ #
57
+ # @return [Hash] The context
58
+ def get_context
59
+ @context
60
+ end
61
+
62
+ private
63
+
64
+ # schema.json declares the draft-07 dialect (since 1.3.0). The json-schema
65
+ # gem implements up to draft-06 and refuses an unknown `$schema`, so the
66
+ # dialect is pinned explicitly and the declaration dropped from the copy it
67
+ # validates with. Draft-07 adds nothing this schema relies on beyond
68
+ # `$comment`, which the gem ignores.
69
+ def validation_schema
70
+ @validation_schema ||= @schema.reject { |key, _| key == '$schema' }
71
+ end
72
+
73
+ def load_json(path)
74
+ JSON.parse(File.read(path))
75
+ rescue Errno::ENOENT => e
76
+ raise SchemaError, "Schema file not found: #{path}"
77
+ rescue JSON::ParserError => e
78
+ raise SchemaError, "Invalid JSON in schema file: #{path}"
79
+ end
80
+
81
+ def parse_resume(resume)
82
+ case resume
83
+ when Hash
84
+ resume
85
+ when String
86
+ JSON.parse(resume)
87
+ else
88
+ raise ValidationError, "Resume must be a Hash or JSON string"
89
+ end
90
+ rescue JSON::ParserError => e
91
+ raise ValidationError, "Invalid JSON: #{e.message}"
92
+ end
93
+
94
+ def format_error(error)
95
+ {
96
+ path: error[:fragment] || '/',
97
+ message: error[:message],
98
+ schema: error[:schema] || {}
99
+ }
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,3 @@
1
+ module SchemaResume
2
+ VERSION = "1.3.2"
3
+ end
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+ require 'json-schema'
3
+ require_relative 'schema_resume/validator'
4
+ require_relative 'schema_resume/version'
5
+
6
+ module SchemaResume
7
+ class Error < StandardError; end
8
+ class ValidationError < Error; end
9
+ class SchemaError < Error; end
10
+
11
+ # Convenience method to validate a resume
12
+ #
13
+ # @param resume [Hash, String] Resume data as hash or JSON string
14
+ # @return [Hash] Validation result with :valid and :errors keys
15
+ def self.validate(resume)
16
+ validator = Validator.new
17
+ validator.validate(resume)
18
+ end
19
+ end
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://schema-resume.org/meta-schema.json",
4
4
  "$comment": "Primary domain: https://schema-resume.org/ | Alternate domain: https://tradik.github.io/schema-resume/",
5
- "title": "Schema Resume Meta-Schema v1.3.0",
5
+ "title": "Schema Resume Meta-Schema v1.3.2",
6
6
  "description": "Self-hosted meta-schema providing validation rules for resume documents without external dependencies",
7
7
  "type": "object",
8
8
  "definitions": {
@@ -3,11 +3,11 @@
3
3
  xmlns:sr="https://schema-resume.org/xml/1.0"
4
4
  targetNamespace="https://schema-resume.org/xml/1.0"
5
5
  elementFormDefault="qualified"
6
- version="1.3.0">
6
+ version="1.3.2">
7
7
 
8
8
  <xs:annotation>
9
9
  <xs:documentation>
10
- Schema Resume XML Schema Definition (XSD) v1.3.0
10
+ Schema Resume XML Schema Definition (XSD) v1.3.2
11
11
  Self-hosted XML schema for CV/Resume validation with work authorization and tools tracking
12
12
 
13
13
  This schema provides comprehensive validation for resume/CV documents in XML format.
@@ -17,7 +17,7 @@
17
17
  Primary domain: https://schema-resume.org/
18
18
  Alternate domain: https://tradik.github.io/schema-resume/
19
19
 
20
- Version: 1.3.0
20
+ Version: 1.3.2
21
21
  License: MIT
22
22
  Repository: https://github.com/tradik/schema-resume
23
23
  </xs:documentation>
data/schemas/schema.json CHANGED
@@ -873,7 +873,7 @@
873
873
  }
874
874
  }
875
875
  },
876
- "title": "Schema Resume v1.3.0",
876
+ "title": "Schema Resume v1.3.2",
877
877
  "description": "Self-hosted JSON-LD schema for CV/Resume parsing and validation with work authorization and tools tracking",
878
878
  "type": "object"
879
879
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-resume-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Schema Resume
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-08-26 00:00:00.000000000 Z
12
+ date: 2026-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-schema
@@ -35,16 +35,22 @@ dependencies:
35
35
  name: json
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.6'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '4.0'
41
44
  type: :runtime
42
45
  prerelease: false
43
46
  version_requirements: !ruby/object:Gem::Requirement
44
47
  requirements:
45
- - - "~>"
48
+ - - ">="
46
49
  - !ruby/object:Gem::Version
47
50
  version: '2.6'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '4.0'
48
54
  - !ruby/object:Gem::Dependency
49
55
  name: rspec
50
56
  requirement: !ruby/object:Gem::Requirement
@@ -84,6 +90,9 @@ extra_rdoc_files: []
84
90
  files:
85
91
  - LICENSE
86
92
  - README.md
93
+ - lib/schema_resume.rb
94
+ - lib/schema_resume/validator.rb
95
+ - lib/schema_resume/version.rb
87
96
  - schemas/context.jsonld
88
97
  - schemas/meta-schema.json
89
98
  - schemas/schema-resume.xsd