Return "is different schema" (page <-> app)
558283
private function isDifferentSchema(ResourceObject $parentRo, ResourceObject $childRo) : bool
    {
        return $parentRo->uri->scheme . $parentRo->uri->host !== $childRo->uri->scheme . $childRo->uri->host;
    }
1339364
def schema(self) -> str:
        
        if self._ssl:
            return "https"
        proxy = bool(self.app and self.app.proxy)
        if not proxy:
            return "http"
        proto = cast(str, self.get("X-Forwarded-Proto") or "http")
        return proto.split(",")[0].strip()
1257329
function validateThemeNotInUseByApps(cb) {
    var appThemeModel = models.get(connections.mongooseConnection, models.MODELNAMES.APP_THEMES);

    appThemeModel.count({"theme" : options._id}, function(err, countAppsUsingTheme) {
      if (err) {
        return cb(err);
      }

      if (countAppsUsingTheme > 0) {
        return cb(new Error("Cannot delete theme in use by apps. Apps Using this theme" + countAppsUsingTheme));
      }

      return cb();
    });
  }
1313378
void compareRecordTypes(Schema oldSchema,
                                                 Schema newSchema,
                                                 List<Message> messages,
                                                 String name) {
        if(oldSchema == null || newSchema == null || oldSchema.getType() != Schema.Type.RECORD) {
            throw new IllegalArgumentException("Old schema must be RECORD type. Name=" + name
                                               + ". Type=" + oldSchema);
        }

        if(newSchema.getType() != Schema.Type.RECORD) {
            messages.add(new Message(Level.ERROR, "Illegal type change from " + oldSchema.getType()
                                                  + " to " + newSchema.getType() + " for field "
                                                  + name));
            return;
        }

        // Check all of the fields in the new schema
        for(Field newField: newSchema.getFields()) {
            String fieldName = newField.name();
            Field oldField = oldSchema.getField(fieldName);

            if(oldField == null) {
                // This is a new field that did not exist in the original
                // schema.
                // Check if it is optional or has a default value.
                if(isOptional(newField)) {
                    if(newField.defaultValue() == null) {
                        messages.add(new Message(Level.INFO, "Added optional field " + name + "."
                                                             + fieldName
                                                             + " with no default value."));
                    } else {
                        messages.add(new Message(Level.INFO, "Added optional field " + name + "."
                                                             + fieldName + " with default value: "
                                                             + newField.defaultValue()));
                    }
                } else {
                    if(newField.defaultValue() == null) {
                        messages.add(new Message(Level.ERROR, "Added required field " + name + "."
                                                              + fieldName
                                                              + " with no default value."));
                    } else {
                        messages.add(new Message(Level.INFO, "Added required field " + name + "."
                                                             + fieldName + " with default value: "
                                                             + newField.defaultValue()));
                    }
                }
            } else {
                // This is a field that existed in the original schema.

                // Check if the field was changed from optional to required or
                // vice versa.
                boolean newFieldIsOptional = isOptional(newField);
                boolean oldFieldIsOptional = isOptional(oldField);

                if(oldFieldIsOptional != newFieldIsOptional) {
                    if(oldFieldIsOptional) {
                        messages.add(new Message(Level.ERROR,
                                                 "Existing field " + name + "." + fieldName
                                                         + " was optional and is now required."));
                    } else {
                        messages.add(new Message(Level.WARN, "Existing field " + name + "."
                                                             + fieldName
                                                             + " was required and is now optional."));
                    }
                }

                // Recursively compare the nested field types
                compareTypes(oldField.schema(), newField.schema(), messages, name + "." + fieldName);

                // Check if the default value has been changed
                if(newField.defaultValue() == null) {
                    if(oldField.defaultValue() != null) {
                        messages.add(new Message(Level.WARN,
                                                 "Removed default value for existing field " + name
                                                         + "." + fieldName
                                                         + ". The old default was: "
                                                         + oldField.defaultValue()));
                    }
                } else // newField.defaultValue() != null
                {
                    if(oldField.defaultValue() == null) {
                        messages.add(new Message(Level.WARN,
                                                 "Added a default value for existing field " + name
                                                         + "." + fieldName
                                                         + ". The new default is: "
                                                         + newField.defaultValue()));
                    } else if(!newField.defaultValue().equals(oldField.defaultValue())) {
                        messages.add(new Message(Level.INFO,
                                                 "Changed the default value for existing field "
                                                         + name + "." + fieldName
                                                         + ". The old default was: "
                                                         + oldField.defaultValue()
                                                         + ". The new default is: "
                                                         + newField.defaultValue()));
                    }
                }
            }

            // For all fields in the new schema (whether or not it existed in
            // the old schema), if there is a default value for this field, make
            // sure it is legal.
            if(newField.defaultValue() != null) {
                checkDefaultValueIsLegal(newField, messages, name + "." + fieldName);
            }
        }

        // Check if any fields were removed.
        for(Field oldField: newSchema.getFields()) {
            String fieldName = oldField.name();
            Field newField = newSchema.getField(fieldName);

            if(newField == null) {
                if(isOptional(oldField)) {
                    messages.add(new Message(Level.INFO, "Removed optional field " + name + "."
                                                         + fieldName));
                } else {
                    messages.add(new Message(Level.WARN, "Removed required field " + name + "."
                                                         + fieldName));
                }
            }
        }

        // Check if indexing was modified or added to any old fields.
        for(Field oldField: oldSchema.getFields()) {
            if(newSchema.getField(oldField.name()) != null) {
                String oldIndexType = oldField.getProp("indexType");
                String newIndexType = newSchema.getField(oldField.name()).getProp("indexType");

                // Check if added indexing.
                if(oldIndexType == null && newIndexType != null) {
                    messages.add(new Message(Level.ERROR,
                                             "Cannot add indexing to "
                                                     + oldField.name()
                                                     + ". Adding indexing to fields created without indexing is not supported."));
                }

                // Check if changed indexing
                if(oldIndexType != null && !oldIndexType.equals(newIndexType)) {
                    messages.add(new Message(Level.ERROR,
                                             "Cannot change indexing from "
                                                     + oldIndexType
                                                     + " to "
                                                     + newIndexType
                                                     + " for "
                                                     + oldField.name()
                                                     + ". Changing indexing method is not supported."));
                }
            }
        }
    }
1172034
function checkForDuplicateIds( page ) {
      const idCount = {};
      forEachArea( page, items => {
         items.forEach( ({ id }) => {
            idCount[ id ] = idCount[ id ] ? idCount[ id ] + 1 : 1;
         } );
      } );

      const duplicates = Object.keys( idCount ).filter( id => idCount[ id ] > 1 );
      if( duplicates.length ) {
         throw formatError( page, `Duplicate widget/composition/layout ID(s): ${duplicates.join( ', ' )}` );
      }
   }
1282560
def check(self, diff):
        """"""
        path = diff.b_path
        contrib_path = self.project.contrib_module_path
        assert pathlib.Path(contrib_path) in pathlib.Path(path).parents
1232008
def schema_array?(value, id, uniqueness_check = true)
      non_empty_array?(value, uniqueness_check) &&
        value.to_enum.with_index.all? do |schema, index|
          full_id = [id, index].join('/')
          valid_schema? schema, full_id
        end
    end
1041856
def migrate_process_schema(self, process, schema, from_state):
        
        if process.type == self.new_type:
            return False

        process.type = self.new_type
        return True
1038825
void compareEnumTypes(Schema oldSchema,
                                               Schema newSchema,
                                               List<Message> messages,
                                               String name) {
        if(oldSchema == null || newSchema == null || oldSchema.getType() != Schema.Type.ENUM) {
            throw new IllegalArgumentException("Old schema must be ENUM type. Name=" + name
                                               + ". Type=" + oldSchema);
        }

        if(newSchema.getType() != Schema.Type.ENUM) {
            messages.add(new Message(Level.ERROR, "Illegal type change from " + oldSchema.getType()
                                                  + " to " + newSchema.getType() + " for field "
                                                  + name));
            return;
        }

        List<String> newEnumSymbols = newSchema.getEnumSymbols();
        List<String> oldEnumSymbols = oldSchema.getEnumSymbols();

        // Check if enum types were added or removed
        if(!newEnumSymbols.containsAll(oldEnumSymbols)) {
            messages.add(new Message(Level.ERROR,
                                     "Existing ENUM field "
                                             + name
                                             + " had one or more enum symbols removed. The old symbols are:"
                                             + oldEnumSymbols + ". The new symbols are: "
                                             + newEnumSymbols));
        }
        if(!oldEnumSymbols.containsAll(newEnumSymbols)) {
            messages.add(new Message(Level.INFO,
                                     "Existing ENUM field "
                                             + name
                                             + " had one or more enum symbols added. The old symbols are:"
                                             + oldEnumSymbols + ". The new symbols are: "
                                             + newEnumSymbols));
        }

        // Check if enum types were reordered.
        if(newEnumSymbols.containsAll(oldEnumSymbols)) {
            for(int i = 0; i < oldEnumSymbols.size(); i++) {
                if(!oldEnumSymbols.get(i).equals(newEnumSymbols.get(i))) {
                    messages.add(new Message(Level.WARN,
                                             "Existing ENUM field "
                                                     + name
                                                     + " had one or more enum symbols reordered. The old symbols are:"
                                                     + oldEnumSymbols + ". The new symbols are: "
                                                     + newEnumSymbols));
                    break;
                }
            }
        }
    }
609267
def validation_schema(name):
    """"""
    schemas = {
        'processor': 'processSchema.json',
        'descriptor': 'descriptorSchema.json',
        'field': 'fieldSchema.json',
        'type': 'typeSchema.json',
    }

    if name not in schemas:
        raise ValueError()

    field_schema_file = finders.find('flow/{}'.format(schemas['field']), all=True)[0]
    with open(field_schema_file, 'r') as fn:
        field_schema = fn.read()

    if name == 'field':
        return json.loads(field_schema.replace('{{PARENT}}', ''))

    schema_file = finders.find('flow/{}'.format(schemas[name]), all=True)[0]
    with open(schema_file, 'r') as fn:
        schema = fn.read()

    return json.loads(schema.replace('{{FIELD}}', field_schema).replace('{{PARENT}}', '/field'))
482842
function SchemaType (path, options, instance) {
  this.path = path;
  this.instance = instance;
  this.validators = [];
  this.setters = [];
  this.getters = [];
  this.options = options;
  this._index = null;
  this.selected;

  for (var i in options) if (this[i] && 'function' == typeof this[i]) {
    // { unique: true, index: true }
    if ('index' == i && this._index) continue;

    var opts = Array.isArray(options[i])
      ? options[i]
      : [options[i]];

    this[i].apply(this, opts);
  }
}
1330340
function(db_schema) {
        var diff_msg = schema.difference(db_schema, false, true);
        if (diff_msg.length > 0) {
          goog.log.log(me.logger, goog.log.Level.FINER, diff_msg);
          setDb(null, new ydn.error.ConstraintError('different schema: ' +
              diff_msg));
        } else {
          setDb(db);
        }
      }
1070658
function dependenciesExists(schema) {
    var deps = DependenciesMap[schema];
    var f = false;
    deps.forEach(function (d) {
        f = SavedSchemas.indexOf(d) > -1
    });
    return f;
}
420432
function checkSchemaHasReferences(schema) {
  if (schema.$ref) {
    return true;
  }

  return Object.values(schema).some((value) => {
    if (_.isArray(value)) {
      return value.some(checkSchemaHasReferences);
    } else if (_.isObject(value)) {
      return checkSchemaHasReferences(value);
    }

    return false;
  });
}
375974
def _verify_type(self, spec, path):
        """"""
        field_type = spec['type']

        if isinstance(field_type, Schema):
            # Nested documents cannot have validation
            if not set(spec.keys()).issubset(set(['type', 'required', 'nullable', 'default'])):
                raise SchemaFormatException("Unsupported field spec item at {}. Items: "+repr(spec.keys()), path)
            return

        elif isinstance(field_type, Array):
            if not isinstance(field_type.contained_type, (type, Schema, Array, types.FunctionType)):
                raise SchemaFormatException("Unsupported field type contained by Array at {}.", path)

        elif not isinstance(field_type, type) and not isinstance(field_type, types.FunctionType):
            raise SchemaFormatException("Unsupported field type at {}. Type must be a type, a function, an Array or another Schema", path)
895400
def check_schema(self):
        """"""
        if self.valid_schema:
            return
        config = self.config
        metadata = self.metadata()
        if 'current_version' not in metadata:
            raise GaugedSchemaError('Gauged schema not found, '
                                    'try a gauged.sync()')
        if metadata['current_version'] != Gauged.VERSION:
            msg = 'The schema is version %s while this Gauged is version %s. '
            msg += 'Try upgrading Gauged and/or running gauged_migrate.py'
            msg = msg % (metadata['current_version'], Gauged.VERSION)
            raise GaugedVersionMismatchError(msg)
        expected_block_size = '%s/%s' % (config.block_size, config.resolution)
        block_size = '%s/%s' % (metadata['block_size'], metadata['resolution'])
        if block_size != expected_block_size:
            msg = 'Expected %s and got %s' % (expected_block_size, block_size)
            warn(msg, GaugedBlockSizeMismatch)
        self.valid_schema = True
1042115
function identifySchema(obj) {
  if (obj) {
    const code = obj.code;
    const action = obj.action;
    const category = Dialect[action];

    if (category) {
      if (action === 'msg' || action == 'invalid-request') {
        // First handle the schemas which are a category unto themselves.
        return category;
      } else if (code) {
        // Then handle codes. Fall through if there is a code,
        // but it doesn't exist for the identified category.
        const categoryCode = category[code];

        if (categoryCode) {
          return categoryCode;
        }
      } else {
        // If there is no code, attempted to fetch the request sub-object.
        return category.request;
      }
    }
    
    if (code) {
      // If there is a code, but it wasn't associated with the identified
      // category (if any), then attempt to locate it in the general responses.
      let category = Dialect.general;

      if (category) {
        return category[code];
      }
    }
  }
}