Class: Hyrax::FlexibleSchemaValidatorService
- Inherits:
-
Object
- Object
- Hyrax::FlexibleSchemaValidatorService
- Defined in:
- app/services/hyrax/flexible_schema_validator_service.rb
Constant Summary collapse
- DEFAULT_SCHEMA =
Hyrax::Engine.root.join('config', 'metadata_profiles', 'm3_json_schema.json')
- REQUIRED_CLASSES =
[ Hyrax.config.admin_set_model, Hyrax.config.collection_model, Hyrax.config.file_set_model ].map { |str| str.gsub(/^::/, '') }
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#schemer ⇒ Object
readonly
Returns the value of attribute schemer.
Instance Method Summary collapse
-
#default_schema ⇒ Pathname
The default JSON schema used when no custom schema is provided.
-
#initialize(profile:, schema: default_schema) ⇒ void
constructor
Initializes a new FlexibleSchemaValidatorService.
-
#required_classes ⇒ Array<String>
Classes that MUST be present in every flexible metadata profile.
-
#validate! ⇒ void
Execute all validation routines and populate #errors with any issues discovered.
Constructor Details
#initialize(profile:, schema: default_schema) ⇒ void
Initializes a new FlexibleSchemaValidatorService.
20 21 22 23 24 25 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 20 def initialize(profile:, schema: default_schema) @profile = profile @schema = schema @schemer = JSONSchemer.schema(schema) @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 12 def errors @errors end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
12 13 14 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 12 def profile @profile end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
12 13 14 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 12 def schema @schema end |
#schemer ⇒ Object (readonly)
Returns the value of attribute schemer.
12 13 14 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 12 def schemer @schemer end |
Instance Method Details
#default_schema ⇒ Pathname
The default JSON schema used when no custom schema is provided.
44 45 46 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 44 def default_schema DEFAULT_SCHEMA end |
#required_classes ⇒ Array<String>
Classes that MUST be present in every flexible metadata profile.
51 52 53 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 51 def required_classes REQUIRED_CLASSES end |
#validate! ⇒ void
This method returns an undefined value.
Execute all validation routines and populate #errors with any issues discovered.
31 32 33 34 35 36 37 38 39 |
# File 'app/services/hyrax/flexible_schema_validator_service.rb', line 31 def validate! validate_required_classes validate_class_availability validate_available_on_classes_defined validate_existing_records_classes_defined validate_schema validate_label_prop end |