cerebral-module-ui-driver
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -10,11 +10,11 @@ 'use strict'; | ||
function beginValidate(_ref) { | ||
var modules = _ref.modules; | ||
var _ref$input = _ref.input; | ||
var driverModuleName = _ref$input.driverModuleName; | ||
var validateForm = _ref$input.validateForm; | ||
var moduleName = _ref$input.moduleName; | ||
var fields = _ref$input.fields; | ||
var state = _ref.state; | ||
var output = _ref.output; | ||
function beginValidate(args) { | ||
var modules = args.modules; | ||
var _args$input = args.input; | ||
var driverModuleName = _args$input.driverModuleName; | ||
var fields = _args$input.fields; | ||
var moduleName = _args$input.moduleName; | ||
var validateForm = _args$input.validateForm; | ||
var state = args.state; | ||
var output = args.output; | ||
@@ -37,3 +37,3 @@ var driverModule = modules[driverModuleName]; | ||
var driverFieldPath = [].concat(_toConsumableArray(driverModule.path), fieldPath); | ||
var value = undefined; | ||
var value = void 0; | ||
if (!validateForm) { | ||
@@ -40,0 +40,0 @@ // single field validation values come from input and may need to be cast |
@@ -10,12 +10,12 @@ 'use strict'; | ||
function doValidate(_ref) { | ||
var modules = _ref.modules; | ||
var _ref$input = _ref.input; | ||
var driverModuleName = _ref$input.driverModuleName; | ||
var moduleName = _ref$input.moduleName; | ||
var fields = _ref$input.fields; | ||
var validateForm = _ref$input.validateForm; | ||
var fieldNames = _ref$input.fieldNames; | ||
var state = _ref.state; | ||
var output = _ref.output; | ||
function doValidate(args) { | ||
var modules = args.modules; | ||
var _args$input = args.input; | ||
var driverModuleName = _args$input.driverModuleName; | ||
var fieldNames = _args$input.fieldNames; | ||
var fields = _args$input.fields; | ||
var moduleName = _args$input.moduleName; | ||
var validateForm = _args$input.validateForm; | ||
var state = args.state; | ||
var output = args.output; | ||
@@ -28,10 +28,13 @@ var driverModule = modules[driverModuleName]; | ||
return new Promise(function (resolve) { | ||
form.fields[field.name].validate(field.typedValue, function (error) { | ||
field.isValidating = false; | ||
if (error) { | ||
field.isValid = false; | ||
field.error = error; | ||
form.fields[field.name].validate(Object.assign({}, args, { | ||
value: field.typedValue, | ||
done: function done(error) { | ||
field.isValidating = false; | ||
if (error) { | ||
field.isValid = false; | ||
field.error = error; | ||
} | ||
resolve(field); | ||
} | ||
resolve(field); | ||
}); | ||
})); | ||
}); | ||
@@ -42,8 +45,11 @@ })).then(function (values) { | ||
var allFields = state.get([].concat(_toConsumableArray(driverModule.path), _toConsumableArray(formModule.path), ['fields'])); | ||
form.validate(Object.keys(allFields).reduce(function (data, name) { | ||
data[name] = allFields[name].typedValue; | ||
return data; | ||
}, {}), function (error) { | ||
return output({ moduleName: moduleName, fields: values, error: error, fieldNames: fieldNames }); | ||
}); | ||
form.validate(Object.assign({}, args, { | ||
values: Object.keys(allFields).reduce(function (data, name) { | ||
data[name] = allFields[name].typedValue; | ||
return data; | ||
}, {}), | ||
done: function done(error) { | ||
output({ moduleName: moduleName, fields: values, error: error, fieldNames: fieldNames }); | ||
} | ||
})); | ||
})(); | ||
@@ -50,0 +56,0 @@ } else { |
@@ -14,6 +14,6 @@ 'use strict'; | ||
var driverModuleName = _args$input.driverModuleName; | ||
var moduleName = _args$input.moduleName; | ||
var fields = _args$input.fields; | ||
var error = _args$input.error; | ||
var fieldNames = _args$input.fieldNames; | ||
var fields = _args$input.fields; | ||
var moduleName = _args$input.moduleName; | ||
var validateForm = _args$input.validateForm; | ||
@@ -20,0 +20,0 @@ var state = args.state; |
{ | ||
"name": "cerebral-module-ui-driver", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "A driver for connecting ui components to cerebral", | ||
@@ -35,4 +35,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"babel-cli": "^6.6.4", | ||
"babel-core": "^6.6.4", | ||
"babel-cli": "^6.6.5", | ||
"babel-core": "^6.6.5", | ||
"babel-preset-es2015": "^6.6.0", | ||
@@ -44,5 +44,5 @@ "baobab": "^2.3.3", | ||
"chai": "^3.5.0", | ||
"eslint": "^2.2.0", | ||
"eslint": "^2.3.0", | ||
"mocha": "^2.4.5", | ||
"moment": "^2.11.2", | ||
"moment": "^2.12.0", | ||
"parallelshell": "^2.0.0", | ||
@@ -49,0 +49,0 @@ "rimraf": "^2.5.2", |
@@ -83,3 +83,3 @@ # cerebral-module-ui-driver | ||
type: 'string', // supported types are string, int, float, date and time | ||
validate (value, done) { //optional | ||
validate ({ value, done }) { //optional | ||
// called if type casting is successful | ||
@@ -91,3 +91,3 @@ done(value.length > 0 ? '' : 'username is required') | ||
type: 'string', | ||
validate (value, done) { // optional | ||
validate ({ value, done }) { // optional | ||
// called if type casting is successful | ||
@@ -94,0 +94,0 @@ done(value.length > 0 ? '' : 'password is required') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41359
714