def validate_id_or_name_with_parent(record_name = nil, parent: 'organization', required: true)
      child_options = IdNameOptionsValidator.build_child_options(record_name)
      parent_options = IdNameOptionsValidator.build_parent_options(parent)

      validate_options :before, 'IdResolution' do
        any(*child_options).required if required

        if (name_option = child_options.detect { |opt| opt.end_with?('_name') }) &&
           option(name_option).exist?
          any(*parent_options).required
        end
      end
    end
def validate_id_or_name_with_parent(record_name = nil, parent: 'organization', required: true)
      child_options = IdNameOptionsValidator.build_child_options(record_name)
      parent_options = IdNameOptionsValidator.build_parent_options(parent)

      validate_options :before, 'IdResolution' do
        any(*child_options).required if required

        if (name_option = child_options.detect { |opt| opt.end_with?('_name') }) &&
           option(name_option).exist?
          any(*parent_options).required
        end
      end
    end
This is a method that requires:
 1. either name or id has been supplied
 2. if name is supplied, parent id/name/etc is also required

 Normally the parent will be organization as with products, content views,
 etc but this could also apply to repos for example whose names are unique
 per product

 Some examples:

 validate_id_or_name_with_parent
 validate_id_or_name_with_parent :content_view
 validate_id_or_name_with_parent :repository, parent: 'product', required: false
 validate_id_or_name_with_parent :content_view, parent: {organization: ['id', 'name']}