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 context support #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add context support #427

wants to merge 1 commit into from

Conversation

o-rumiantsev
Copy link
Member

No description provided.

@o-rumiantsev o-rumiantsev self-assigned this May 24, 2019
@o-rumiantsev o-rumiantsev force-pushed the add-context-support branch 3 times, most recently from 5710c76 to 475a40a Compare May 24, 2019 06:41
@nechaido nechaido requested a review from lundibundi May 24, 2019 08:09
lib/metaschema-config/context.js Outdated Show resolved Hide resolved
lib/metaschema-config/context.js Outdated Show resolved Hide resolved
context: 'context',
};

const dataTypes = ['domain', 'category', 'context'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const dataTypes = ['domain', 'category', 'context'];
const dataTypes = Object.keys(propToTypes);

const { options, config } = require('../lib/metaschema-config/config');

const { MetaschemaError, SchemaValidationError } = metaschema.errors;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a positive test, to ensure that it is possible to use context args in actions.


const addContext = (context, ms) => {
const errors = [];
const duplicateContext = ms.context.size > 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is not a suitable variable name. Maybe something like isContextDuplicate or isContextExist.

@@ -6,34 +6,23 @@ const {
extractDecorator,
} = require('metaschema');

const propToTypes = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const propToTypes = {

WDYT?

context: 'context',
};

const dataTypes = Object.keys(propToTypes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const dataTypes = Object.keys(propToTypes);
const dataTypes = ['domain', 'category', 'context'];

for (const type of dataTypes) {
const value = field[type];
if (value) {
const def = ms[propToTypes[type]].get(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type === 'domain' ? 'domains' : type;
const def = ms[type].get(value);

};

const dataTypes = Object.keys(propToTypes);
const getDefinition = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getDefinition = {
const getDefinition = type => schema => type === 'category' ? schema.definition : schema;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think, it is better to write like this:

const getDefinition = (type, schema) => type === 'category' ? schema.definition : schema

new SchemaValidationError('unresolved', `${source}.${key}`, info)
);
} else {
field.definition = getDefinition[type](def);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
field.definition = getDefinition[type](def);
field.definition = getDefinition(type)(def);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants