calidation
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -43,11 +43,16 @@ 'use strict'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Validation.__proto__ || Object.getPrototypeOf(Validation)).call.apply(_ref, [this].concat(args))), _this), _this.getFieldValues = function () { | ||
var _this$props = _this.props, | ||
config = _this$props.config, | ||
fields = _this$props.fields, | ||
initialValues = _this$props.initialValues; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Validation.__proto__ || Object.getPrototypeOf(Validation)).call.apply(_ref, [this].concat(args))), _this), _this.getFields = function (source) { | ||
var config = _this.props.config; | ||
var getFirstDefinedValue = function getFirstDefinedValue() { | ||
for (var _len2 = arguments.length, values = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
values[_key2] = arguments[_key2]; | ||
} | ||
return values.find(function (value) { | ||
return value !== undefined; | ||
}); | ||
}; | ||
return Object.keys(config).reduce(function (allFields, field) { | ||
return _extends({}, allFields, _defineProperty({}, field, fields[field] || initialValues[field] || '')); | ||
return _extends({}, allFields, _defineProperty({}, field, getFirstDefinedValue(source[field], ''))); | ||
}, {}); | ||
@@ -60,3 +65,8 @@ }, _temp), _possibleConstructorReturn(_this, _ret); | ||
value: function componentDidMount() { | ||
this.props.register(this.props.config, this.getFieldValues()); | ||
var _props = this.props, | ||
register = _props.register, | ||
initialValues = _props.initialValues, | ||
config = _props.config; | ||
register(config, this.getFields(initialValues)); | ||
} | ||
@@ -71,9 +81,9 @@ }, { | ||
value: function render() { | ||
var _props = this.props, | ||
errors = _props.errors, | ||
fields = _props.fields, | ||
submitted = _props.submitted, | ||
children = _props.children, | ||
config = _props.config, | ||
setField = _props.setField; | ||
var _props2 = this.props, | ||
errors = _props2.errors, | ||
fields = _props2.fields, | ||
submitted = _props2.submitted, | ||
children = _props2.children, | ||
config = _props2.config, | ||
setField = _props2.setField; | ||
@@ -83,3 +93,3 @@ | ||
errors: errors, | ||
fields: this.getFieldValues(), | ||
fields: this.getFields(fields), | ||
submitted: submitted, | ||
@@ -86,0 +96,0 @@ setField: setField |
{ | ||
"name": "calidation", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "A red hot validation library for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
39923
422