| 276 | } |
| 277 | |
| 278 | static validateSchemaOptions(schema: SchemaOptions) { |
| 279 | if (!schema) { return; } |
| 280 | if (Object.prototype.toString.call(schema) !== '[object Object]') { |
| 281 | throw 'Parse Server option schema must be an object.'; |
| 282 | } |
| 283 | if (schema.definitions === undefined) { |
| 284 | schema.definitions = SchemaOptions.definitions.default; |
| 285 | } else if (!Array.isArray(schema.definitions)) { |
| 286 | throw 'Parse Server option schema.definitions must be an array.'; |
| 287 | } |
| 288 | if (schema.strict === undefined) { |
| 289 | schema.strict = SchemaOptions.strict.default; |
| 290 | } else if (!isBoolean(schema.strict)) { |
| 291 | throw 'Parse Server option schema.strict must be a boolean.'; |
| 292 | } |
| 293 | if (schema.deleteExtraFields === undefined) { |
| 294 | schema.deleteExtraFields = SchemaOptions.deleteExtraFields.default; |
| 295 | } else if (!isBoolean(schema.deleteExtraFields)) { |
| 296 | throw 'Parse Server option schema.deleteExtraFields must be a boolean.'; |
| 297 | } |
| 298 | if (schema.recreateModifiedFields === undefined) { |
| 299 | schema.recreateModifiedFields = SchemaOptions.recreateModifiedFields.default; |
| 300 | } else if (!isBoolean(schema.recreateModifiedFields)) { |
| 301 | throw 'Parse Server option schema.recreateModifiedFields must be a boolean.'; |
| 302 | } |
| 303 | if (schema.lockSchemas === undefined) { |
| 304 | schema.lockSchemas = SchemaOptions.lockSchemas.default; |
| 305 | } else if (!isBoolean(schema.lockSchemas)) { |
| 306 | throw 'Parse Server option schema.lockSchemas must be a boolean.'; |
| 307 | } |
| 308 | if (schema.beforeMigration === undefined) { |
| 309 | schema.beforeMigration = null; |
| 310 | } else if (schema.beforeMigration !== null && typeof schema.beforeMigration !== 'function') { |
| 311 | throw 'Parse Server option schema.beforeMigration must be a function.'; |
| 312 | } |
| 313 | if (schema.afterMigration === undefined) { |
| 314 | schema.afterMigration = null; |
| 315 | } else if (schema.afterMigration !== null && typeof schema.afterMigration !== 'function') { |
| 316 | throw 'Parse Server option schema.afterMigration must be a function.'; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | static validatePagesOptions(pages) { |
| 321 | if (Object.prototype.toString.call(pages) !== '[object Object]') { |