Skip to content

Commit

Permalink
Fix: Validation Bug (#1491)
Browse files Browse the repository at this point in the history
* bug solved

* unnecessary modifications deleted

* log message added

* const removed

* const's combined

Co-authored-by: Pedro Rosario <pedrorosario@intellisys.com.do>
  • Loading branch information
CristianUser and Pedro Rosario authored Sep 18, 2020
1 parent 849a1a4 commit 82df823
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions lib/preloader/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import getSites from './sites';
import parseUrl from './parse-url';
import { hasAnyBehaviors, convertSchema } from '../core-data/behaviors2input';
import { getItem } from '../utils/local';
import logger from '../utils/log';


/**
* @module preloader
*/

const hbs = clayHBS();
const hbs = clayHBS(),
log = logger(__filename);

/**
* get component models so we can mount them on window.kiln.componentModels
Expand Down Expand Up @@ -135,10 +138,16 @@ function getSchemas(schemas, kilnjs) {
schema = convertSchema(schema, name);
}

const kilnFile = kilnjs[name];
const kilnJsFile = kilnjs[name];

if (kilnJsFile) {
const kilnFileSchema = kilnJsFile({ ..._.cloneDeep(schema), schemaName: name });

if (kilnFile) {
schema = kilnFile({ ..._.cloneDeep(schema), schemaName: name });
if (kilnFileSchema) {
schema = kilnFileSchema;
} else {
log.warn(`The kiln.js file of (${name}) component is returning undefined`, { action: 'loading kiln.js file', schema: name });
}
}

return schema;
Expand Down
2 changes: 1 addition & 1 deletion lib/validators/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function runKilnjsValidators(schemas = {}, components = {}) {
export function getSchemasWithValidationRules(schemas = {}) {
const validationSchemas = {};

Object.keys(schemas).forEach(schemaName => schemas[schemaName].validation ? validationSchemas[schemaName] = _.cloneDeep(schemas[schemaName]) : null);
Object.keys(schemas).forEach(schemaName => _.has(schemas, `${schemaName}.validation`) ? validationSchemas[schemaName] = _.cloneDeep(schemas[schemaName]) : null);

return validationSchemas;
}
Expand Down

0 comments on commit 82df823

Please sign in to comment.