app/services/mutation_operations/contract.rb
# Validate cases where we are assigning a new schema to an entity, and we need to check if the parent is okay.
#
# @todo Checking children will be automated later.
#
# @see Mutations::Contracts::AlterSchemaVersion
Validate cases where we are assigning a new schema to an entity, and we need to check if the parent is okay.
Validate cases where we are assigning a new schema to an entity and we need to check if the parent is okay .
def validate_association_between_contextual_parent_and_new_schema_version!(child_key: :entity, schema_key: :schema_version_slug)
        rule(child_key, schema_key) do
          parent_value = values[child_key].contextual_parent
          child_value = loaded_schema_version
          validate_association.call(parent_value, child_value) do |m|
            m.valid do |_|
            end
            m.mutually_invalid do |err|
              key(child_key).failure(:invalid_new_schema_for_parent, declaration: err.child.provided_declaration)
              key(schema_key).failure(:invalid_parent_for_schema, declaration: err.parent.provided_declaration)
            end
            m.invalid_child do |err|
              key(child_key).failure(:invalid_new_schema_for_parent, declaration: err.provided_declaration)
            end
            m.invalid_parent do |err|
              key(schema_key).failure(:invalid_parent_for_schema, declaration: err.provided_declaration)
            end
          end if has_loaded_schema_version?
        end
      end
def validate_association_between_contextual_parent_and_new_schema_version! ( child_key : :entity , schema_key : :schema_version_slug ) rule ( child_key , schema_key ) do parent_value = values [ child_key ] . contextual_parent child_value = loaded_schema_version validate_association . call ( parent_value , child_value ) do | m | m . valid do | _ | end m . mutually_invalid do | err | key ( child_key ) . failure ( :invalid_new_schema_for_parent , declaration : err . child . provided_declaration ) key ( schema_key ) . failure ( :invalid_parent_for_schema , declaration : err . parent . provided_declaration ) end m . invalid_child do | err | key ( child_key ) . failure ( :invalid_new_schema_for_parent , declaration : err . provided_declaration ) end m . invalid_parent do | err | key ( schema_key ) . failure ( :invalid_parent_for_schema , declaration : err . provided_declaration ) end end if has_loaded_schema_version? end end
Validate cases where we are assigning a new schema to an entity, and we need to check if the parent is okay.
Validate cases where we are assigning a new schema to an entity and we need to check if the parent is okay .
# we're okay
child_key
schema_key
todo
Checking children will be automated later.
Checking children will be automated later .
see
None