Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for save and get raw definition #395

Merged
merged 6 commits into from Apr 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions package/lib/SimpleSchema.js
Expand Up @@ -57,6 +57,7 @@ class SimpleSchema {
humanizeAutoLabels = true,
requiredByDefault = true,
tracker,
keepRawDefinition = false,
} = {}) {
// Stash the options object
this._constructorOptions = {
Expand Down Expand Up @@ -91,12 +92,22 @@ class SimpleSchema {
this._depsLabels = {};
this.extend(schema);

// Clone raw definition and save if keepRawDefinition is active
this._rawDefinition = keepRawDefinition && schema;
AndyCC25 marked this conversation as resolved.
Show resolved Hide resolved

// Define default validation error messages
this.messageBox = new MessageBox(clone(defaultMessages));

this.version = SimpleSchema.version;
}

/**
/* @returns {Object} The entire raw schema definition passed in the constructor
*/
get rawDefinition() {
return this._rawDefinition;
}

forEachAncestorSimpleSchema(key, func) {
const genericKey = MongoObject.makeKeyGeneric(key);

Expand Down