Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

final-form

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

final-form - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

209

dist/final-form.cjs.js

@@ -460,6 +460,7 @@ 'use strict';

}
var initialValues = config.initialValues,
var debug = config.debug,
initialValues = config.initialValues,
onSubmit = config.onSubmit,
validate = config.validate,
debug = config.debug;
validateOnBlur = config.validateOnBlur;

@@ -491,95 +492,100 @@ if (!onSubmit) {

var runFieldLevelValidation = function runFieldLevelValidation(name, allValues, callback) {
var field = state.fields[name];
var runRecordLevelValidation = function runRecordLevelValidation(setError) {
var promises = [];
if (validate) {
var processErrors = function processErrors(errors) {
state.error = errors[FORM_ERROR];
Object.keys(state.fields).forEach(function (key) {
setError(key, getIn(errors, key));
});
};
var errorsOrPromise = validate(state.formState.values);
if (isPromise(errorsOrPromise)) {
promises.push(errorsOrPromise.then(processErrors));
} else {
processErrors(errorsOrPromise);
}
}
return promises;
};
var runFieldLevelValidation = function runFieldLevelValidation(field, setError) {
var validators = field.validators;
var promises = [];
var validatorKeys = Object.keys(validators);
var returned = false;
if (validatorKeys.length) {
var remaining = validatorKeys.length;
validatorKeys.forEach(function (index) {
var processError = function processError(error) {
remaining--;
if (remaining === 0 || !returned && error) {
callback(error);
returned = true;
}
};
if (!returned) {
var validator = validators[Number(index)];
var error = validator(field.value, allValues, processError);
if (error && isPromise(error)) {
error.then(processError, processError);
} else if (validator.length < 3) {
// not using callback, so undefined means that's the result of the validation
processError(error);
}
var error = void 0;
Object.keys(validators).forEach(function (index) {
var validator = validators[Number(index)];
var errorOrPromise = validator(field.value, state.formState.values);
if (errorOrPromise && isPromise(errorOrPromise)) {
promises.push(errorOrPromise.then(setError));
} else if (!error) {
// first registered validator wins
error = errorOrPromise;
}
});
} else {
callback();
setError(error);
}
return promises;
};
var runValidation = function runValidation(callback) {
var fields = state.fields,
values = state.formState.values;
var fields = state.fields;
state.validating++;
var fieldKeys = Object.keys(fields);
if (validate) {
var processValidationErrors = function processValidationErrors(errors) {
// assign errors to each field
state.error = errors[FORM_ERROR];
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (fieldKeys.length) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (localError) {
var recordError = getIn(errors, key);
fields[key].error = localError || recordError; // local overrides record
remaining--;
finish();
});
});
} else {
finish();
}
if (!validate && !fieldKeys.some(function (key) {
return fields[key].validators && Object.keys(fields[key].validators).length;
})) {
if (callback) {
callback();
}
return; // no validation rules
}
// sync version of setError
var recordLevelErrors = {};
var fieldLevelErrors = {};
var setRecordLevelError = function setRecordLevelError(name, error) {
recordLevelErrors[name] = error;
};
var setFieldLevelError = function setFieldLevelError(name, error) {
fieldLevelErrors[name] = error;
};
var promises = [].concat(toConsumableArray(runRecordLevelValidation(function (name, error) {
return setRecordLevelError(name, error);
})), toConsumableArray(fieldKeys.reduce(function (result, name) {
return [].concat(toConsumableArray(result), toConsumableArray(runFieldLevelValidation(fields[name], function (error) {
return setFieldLevelError(name, error);
})));
}, [])));
// process sync errors
fieldKeys.forEach(function (name) {
// field-level errors take precedent over record-level errors
fields[name].error = fieldLevelErrors[name] || recordLevelErrors[name];
});
if (promises.length) {
// sync errors have been set. notify listeners while we wait for others
state.validating++;
if (callback) {
callback();
}
// reassign setError functions for async responses
setRecordLevelError = setFieldLevelError = function setFieldLevelError(name, error) {
fields[name].error = error;
};
var errors = validate(values, processValidationErrors);
if (errors) {
if (isPromise(errors)) {
errors.then(processValidationErrors, processValidationErrors);
} else {
processValidationErrors(errors);
Promise.all(promises).then(function () {
state.validating--;
if (callback) {
callback();
}
}
} else {
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (remaining) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (error) {
fields[key].error = error;
remaining--;
finish();
});
});
} else {
finish();
}
});
} else if (callback) {
callback();
}

@@ -635,4 +641,3 @@ };

var validating = state.validating > 0;
if (pristine === formState.pristine && valid === formState.valid && validating === formState.validating && state.error === formState.error && state.lastFormState && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
if (pristine === formState.pristine && valid === formState.valid && state.error === formState.error && state.lastFormState && state.lastFormState.validating === validating && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
return state.lastFormState;

@@ -687,3 +692,8 @@ }

runValidation(); // generate initial error (even with no fields yet) if we need to
// generate initial error (even with no fields yet) if we need to
runValidation();
// runValidation(() => {
// notifyFieldListeners()
// notifyFormListeners()
// })

@@ -711,4 +721,11 @@ var api = {

});
notifyFieldListeners();
notifyFormListeners();
if (validateOnBlur) {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
} else {
notifyFieldListeners();
notifyFormListeners();
}
}

@@ -725,6 +742,11 @@ },

notifyFormListeners();
runValidation(function () {
if (validateOnBlur) {
notifyFieldListeners();
notifyFormListeners();
});
} else {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
}
}

@@ -818,3 +840,2 @@ },

var validationReturned = false;
runValidation(function () {

@@ -826,8 +847,3 @@ notifyFormListeners();

notifyFieldListeners();
validationReturned = true;
});
if (!validationReturned) {
// validation must be async
firstNotification();
}

@@ -857,2 +873,7 @@ return function () {

if (hasSyncErrors()) {
// mark all fields as touched
Object.keys(fields).forEach(function (key) {
fields[key].touched = true;
});
notifyFieldListeners();
return; // no submit for you!!

@@ -859,0 +880,0 @@ }

@@ -456,6 +456,7 @@ //

}
var initialValues = config.initialValues,
var debug = config.debug,
initialValues = config.initialValues,
onSubmit = config.onSubmit,
validate = config.validate,
debug = config.debug;
validateOnBlur = config.validateOnBlur;

@@ -487,95 +488,100 @@ if (!onSubmit) {

var runFieldLevelValidation = function runFieldLevelValidation(name, allValues, callback) {
var field = state.fields[name];
var runRecordLevelValidation = function runRecordLevelValidation(setError) {
var promises = [];
if (validate) {
var processErrors = function processErrors(errors) {
state.error = errors[FORM_ERROR];
Object.keys(state.fields).forEach(function (key) {
setError(key, getIn(errors, key));
});
};
var errorsOrPromise = validate(state.formState.values);
if (isPromise(errorsOrPromise)) {
promises.push(errorsOrPromise.then(processErrors));
} else {
processErrors(errorsOrPromise);
}
}
return promises;
};
var runFieldLevelValidation = function runFieldLevelValidation(field, setError) {
var validators = field.validators;
var promises = [];
var validatorKeys = Object.keys(validators);
var returned = false;
if (validatorKeys.length) {
var remaining = validatorKeys.length;
validatorKeys.forEach(function (index) {
var processError = function processError(error) {
remaining--;
if (remaining === 0 || !returned && error) {
callback(error);
returned = true;
}
};
if (!returned) {
var validator = validators[Number(index)];
var error = validator(field.value, allValues, processError);
if (error && isPromise(error)) {
error.then(processError, processError);
} else if (validator.length < 3) {
// not using callback, so undefined means that's the result of the validation
processError(error);
}
var error = void 0;
Object.keys(validators).forEach(function (index) {
var validator = validators[Number(index)];
var errorOrPromise = validator(field.value, state.formState.values);
if (errorOrPromise && isPromise(errorOrPromise)) {
promises.push(errorOrPromise.then(setError));
} else if (!error) {
// first registered validator wins
error = errorOrPromise;
}
});
} else {
callback();
setError(error);
}
return promises;
};
var runValidation = function runValidation(callback) {
var fields = state.fields,
values = state.formState.values;
var fields = state.fields;
state.validating++;
var fieldKeys = Object.keys(fields);
if (validate) {
var processValidationErrors = function processValidationErrors(errors) {
// assign errors to each field
state.error = errors[FORM_ERROR];
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (fieldKeys.length) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (localError) {
var recordError = getIn(errors, key);
fields[key].error = localError || recordError; // local overrides record
remaining--;
finish();
});
});
} else {
finish();
}
if (!validate && !fieldKeys.some(function (key) {
return fields[key].validators && Object.keys(fields[key].validators).length;
})) {
if (callback) {
callback();
}
return; // no validation rules
}
// sync version of setError
var recordLevelErrors = {};
var fieldLevelErrors = {};
var setRecordLevelError = function setRecordLevelError(name, error) {
recordLevelErrors[name] = error;
};
var setFieldLevelError = function setFieldLevelError(name, error) {
fieldLevelErrors[name] = error;
};
var promises = [].concat(toConsumableArray(runRecordLevelValidation(function (name, error) {
return setRecordLevelError(name, error);
})), toConsumableArray(fieldKeys.reduce(function (result, name) {
return [].concat(toConsumableArray(result), toConsumableArray(runFieldLevelValidation(fields[name], function (error) {
return setFieldLevelError(name, error);
})));
}, [])));
// process sync errors
fieldKeys.forEach(function (name) {
// field-level errors take precedent over record-level errors
fields[name].error = fieldLevelErrors[name] || recordLevelErrors[name];
});
if (promises.length) {
// sync errors have been set. notify listeners while we wait for others
state.validating++;
if (callback) {
callback();
}
// reassign setError functions for async responses
setRecordLevelError = setFieldLevelError = function setFieldLevelError(name, error) {
fields[name].error = error;
};
var errors = validate(values, processValidationErrors);
if (errors) {
if (isPromise(errors)) {
errors.then(processValidationErrors, processValidationErrors);
} else {
processValidationErrors(errors);
Promise.all(promises).then(function () {
state.validating--;
if (callback) {
callback();
}
}
} else {
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (remaining) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (error) {
fields[key].error = error;
remaining--;
finish();
});
});
} else {
finish();
}
});
} else if (callback) {
callback();
}

@@ -631,4 +637,3 @@ };

var validating = state.validating > 0;
if (pristine === formState.pristine && valid === formState.valid && validating === formState.validating && state.error === formState.error && state.lastFormState && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
if (pristine === formState.pristine && valid === formState.valid && state.error === formState.error && state.lastFormState && state.lastFormState.validating === validating && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
return state.lastFormState;

@@ -683,3 +688,8 @@ }

runValidation(); // generate initial error (even with no fields yet) if we need to
// generate initial error (even with no fields yet) if we need to
runValidation();
// runValidation(() => {
// notifyFieldListeners()
// notifyFormListeners()
// })

@@ -707,4 +717,11 @@ var api = {

});
notifyFieldListeners();
notifyFormListeners();
if (validateOnBlur) {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
} else {
notifyFieldListeners();
notifyFormListeners();
}
}

@@ -721,6 +738,11 @@ },

notifyFormListeners();
runValidation(function () {
if (validateOnBlur) {
notifyFieldListeners();
notifyFormListeners();
});
} else {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
}
}

@@ -814,3 +836,2 @@ },

var validationReturned = false;
runValidation(function () {

@@ -822,8 +843,3 @@ notifyFormListeners();

notifyFieldListeners();
validationReturned = true;
});
if (!validationReturned) {
// validation must be async
firstNotification();
}

@@ -853,2 +869,7 @@ return function () {

if (hasSyncErrors()) {
// mark all fields as touched
Object.keys(fields).forEach(function (key) {
fields[key].touched = true;
});
notifyFieldListeners();
return; // no submit for you!!

@@ -855,0 +876,0 @@ }

@@ -462,6 +462,7 @@ (function (global, factory) {

}
var initialValues = config.initialValues,
var debug = config.debug,
initialValues = config.initialValues,
onSubmit = config.onSubmit,
validate = config.validate,
debug = config.debug;
validateOnBlur = config.validateOnBlur;

@@ -493,95 +494,100 @@ if (!onSubmit) {

var runFieldLevelValidation = function runFieldLevelValidation(name, allValues, callback) {
var field = state.fields[name];
var runRecordLevelValidation = function runRecordLevelValidation(setError) {
var promises = [];
if (validate) {
var processErrors = function processErrors(errors) {
state.error = errors[FORM_ERROR];
Object.keys(state.fields).forEach(function (key) {
setError(key, getIn(errors, key));
});
};
var errorsOrPromise = validate(state.formState.values);
if (isPromise(errorsOrPromise)) {
promises.push(errorsOrPromise.then(processErrors));
} else {
processErrors(errorsOrPromise);
}
}
return promises;
};
var runFieldLevelValidation = function runFieldLevelValidation(field, setError) {
var validators = field.validators;
var promises = [];
var validatorKeys = Object.keys(validators);
var returned = false;
if (validatorKeys.length) {
var remaining = validatorKeys.length;
validatorKeys.forEach(function (index) {
var processError = function processError(error) {
remaining--;
if (remaining === 0 || !returned && error) {
callback(error);
returned = true;
}
};
if (!returned) {
var validator = validators[Number(index)];
var error = validator(field.value, allValues, processError);
if (error && isPromise(error)) {
error.then(processError, processError);
} else if (validator.length < 3) {
// not using callback, so undefined means that's the result of the validation
processError(error);
}
var error = void 0;
Object.keys(validators).forEach(function (index) {
var validator = validators[Number(index)];
var errorOrPromise = validator(field.value, state.formState.values);
if (errorOrPromise && isPromise(errorOrPromise)) {
promises.push(errorOrPromise.then(setError));
} else if (!error) {
// first registered validator wins
error = errorOrPromise;
}
});
} else {
callback();
setError(error);
}
return promises;
};
var runValidation = function runValidation(callback) {
var fields = state.fields,
values = state.formState.values;
var fields = state.fields;
state.validating++;
var fieldKeys = Object.keys(fields);
if (validate) {
var processValidationErrors = function processValidationErrors(errors) {
// assign errors to each field
state.error = errors[FORM_ERROR];
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (fieldKeys.length) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (localError) {
var recordError = getIn(errors, key);
fields[key].error = localError || recordError; // local overrides record
remaining--;
finish();
});
});
} else {
finish();
}
if (!validate && !fieldKeys.some(function (key) {
return fields[key].validators && Object.keys(fields[key].validators).length;
})) {
if (callback) {
callback();
}
return; // no validation rules
}
// sync version of setError
var recordLevelErrors = {};
var fieldLevelErrors = {};
var setRecordLevelError = function setRecordLevelError(name, error) {
recordLevelErrors[name] = error;
};
var setFieldLevelError = function setFieldLevelError(name, error) {
fieldLevelErrors[name] = error;
};
var promises = [].concat(toConsumableArray(runRecordLevelValidation(function (name, error) {
return setRecordLevelError(name, error);
})), toConsumableArray(fieldKeys.reduce(function (result, name) {
return [].concat(toConsumableArray(result), toConsumableArray(runFieldLevelValidation(fields[name], function (error) {
return setFieldLevelError(name, error);
})));
}, [])));
// process sync errors
fieldKeys.forEach(function (name) {
// field-level errors take precedent over record-level errors
fields[name].error = fieldLevelErrors[name] || recordLevelErrors[name];
});
if (promises.length) {
// sync errors have been set. notify listeners while we wait for others
state.validating++;
if (callback) {
callback();
}
// reassign setError functions for async responses
setRecordLevelError = setFieldLevelError = function setFieldLevelError(name, error) {
fields[name].error = error;
};
var errors = validate(values, processValidationErrors);
if (errors) {
if (isPromise(errors)) {
errors.then(processValidationErrors, processValidationErrors);
} else {
processValidationErrors(errors);
Promise.all(promises).then(function () {
state.validating--;
if (callback) {
callback();
}
}
} else {
var remaining = fieldKeys.length;
var finish = function finish() {
if (remaining === 0) {
state.validating--;
if (callback) {
callback();
}
}
};
if (remaining) {
fieldKeys.forEach(function (key) {
runFieldLevelValidation(key, values, function (error) {
fields[key].error = error;
remaining--;
finish();
});
});
} else {
finish();
}
});
} else if (callback) {
callback();
}

@@ -637,4 +643,3 @@ };

var validating = state.validating > 0;
if (pristine === formState.pristine && valid === formState.valid && validating === formState.validating && state.error === formState.error && state.lastFormState && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
if (pristine === formState.pristine && valid === formState.valid && state.error === formState.error && state.lastFormState && state.lastFormState.validating === validating && state.lastFormState.values === formState.values && state.lastFormState.active === formState.active) {
return state.lastFormState;

@@ -689,3 +694,8 @@ }

runValidation(); // generate initial error (even with no fields yet) if we need to
// generate initial error (even with no fields yet) if we need to
runValidation();
// runValidation(() => {
// notifyFieldListeners()
// notifyFormListeners()
// })

@@ -713,4 +723,11 @@ var api = {

});
notifyFieldListeners();
notifyFormListeners();
if (validateOnBlur) {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
} else {
notifyFieldListeners();
notifyFormListeners();
}
}

@@ -727,6 +744,11 @@ },

notifyFormListeners();
runValidation(function () {
if (validateOnBlur) {
notifyFieldListeners();
notifyFormListeners();
});
} else {
runValidation(function () {
notifyFieldListeners();
notifyFormListeners();
});
}
}

@@ -820,3 +842,2 @@ },

var validationReturned = false;
runValidation(function () {

@@ -828,8 +849,3 @@ notifyFormListeners();

notifyFieldListeners();
validationReturned = true;
});
if (!validationReturned) {
// validation must be async
firstNotification();
}

@@ -859,2 +875,7 @@ return function () {

if (hasSyncErrors()) {
// mark all fields as touched
Object.keys(fields).forEach(function (key) {
fields[key].touched = true;
});
notifyFieldListeners();
return; // no submit for you!!

@@ -861,0 +882,0 @@ }

@@ -1,2 +0,2 @@

!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(e["final-form"]={})}(this,function(e){"use strict";function i(e,i,t,r,n){var a=n(t,r,i,arguments.length>5&&void 0!==arguments[5]&&arguments[5]);a&&e(a)}function t(e,t,r,n){var a=e.entries;Object.keys(a).forEach(function(e){var o=a[Number(e)],u=o.subscription;i(o.subscriber,u,t,r,n)})}var r=function(e){if(null===e||void 0===e)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.length?e.split(/[.[\]]+/).filter(Boolean):[]},n=function(e,i){var t=r(i),n=e,a=!0,o=!1,u=void 0;try{for(var s,l=t[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var c=s.value;if(void 0===n||null===n||!isNaN(n))return;if(Array.isArray(n)&&isNaN(c))return;n=n[c]}}catch(e){o=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(o)throw u}}return n},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e},u=Object.assign||function(e){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},s=function(e){if(Array.isArray(e)){for(var i=0,t=Array(e.length);i<e.length;i++)t[i]=e[i];return t}return Array.from(e)},l=function e(i,t,r,n){if(t>=r.length)return n;var a=r[t];if(isNaN(a)){if(void 0===i||null===i){var l=e(void 0,t+1,r,n);return void 0===l?void 0:o({},a,l)}if(Array.isArray(i))throw new Error("Cannot set a non-numeric property on an array");var c=e(i[a],t+1,r,n),f=Object.keys(i).length;return void 0===c&&(void 0===i[a]&&0===f||void 0!==i[a]&&f<=1)?void 0:u({},i,o({},a,c))}var d=Number(a);if(void 0===i||null===i){var v=e(void 0,t+1,r,n);if(void 0===v)return;var b=[];return b[d]=v,b}if(!Array.isArray(i))throw new Error("Cannot set a numeric property on an object");var m=i[d],h=e(m,t+1,r,n);if(void 0!==h||!(void 0===m&&0===i.length||void 0!==m&&1===i.length)){var y=[].concat(s(i));return void 0===h?y.splice(d,1):y[d]=h,y}},c=function(e,i,t){if(void 0===e||null===e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(void 0===i||null===i)throw new Error("Cannot call setIn() with "+String(i)+" key");return l(e,0,r(i),t)},f=function(e,i){var t=e.submitFailed,r=e.submitSucceeded,n=i.active,a=i.blur,o=i.change,u=i.error,s=i.focus,l=i.initial,c=i.name,f=i.submitError,d=i.touched,v=i.value,b=i.visited,m=l===v,h=!u&&!f;return{active:n,blur:a,change:o,dirty:!m,error:u,focus:s,initial:l,invalid:!h,name:c,pristine:m,submitError:f,submitFailed:t,submitSucceeded:r,touched:d,valid:h,value:v,visited:b}},d=["active","dirty","error","initial","invalid","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],v=function(e,i,t,r,n){var a=!1;return n.forEach(function(n){r[n]&&(e[n]=i[n],t&&i[n]===t[n]||(a=!0))}),a},b=function(e,i,t,r){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return v(n,e,i,t,d)||!i||r?n:void 0},m=["active","dirty","error","initialValues","invalid","pristine","submitting","submitError","submitFailed","submitSucceeded","valid","validating","values"],h=function(e,i,t,r){var n={};return v(n,e,i,t,m)||!i||r?n:void 0},y=function(e,i){if(e===i)return!0;if("object"!==(void 0===e?"undefined":a(e))||!e||"object"!==(void 0===i?"undefined":a(i))||!i)return!1;var t=Object.keys(e),r=Object.keys(i);if(t.length!==r.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(i),o=0;o<t.length;o++){var u=t[o];if(!n(u)||e[u]!==i[u])return!1}return!0},g=function(e){var i=void 0,t=void 0;return function(){for(var r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];return i&&n.length===i.length&&!n.some(function(e,t){return!y(i[t],e)})||(i=n,t=e.apply(void 0,n)),t}},S=function(e){return!!e&&("object"===(void 0===e?"undefined":a(e))||"function"==typeof e)&&"function"==typeof e.then},p=Symbol("form-error"),E=function(e){return{active:e.active,dirty:e.dirty,error:e.error,invalid:e.invalid,initialValues:e.initialValues,pristine:e.pristine,submitting:e.submitting,submitFailed:e.submitFailed,submitSucceeded:e.submitSucceeded,submitError:e.submitError,valid:e.valid,validating:e.validating,values:e.values}},F=function(e){var i=e.active,t=e.blur,r=e.change,n=e.error,a=e.focus,o=e.initial,u=(e.lastFieldState,e.name),s=e.submitError,l=e.touched,c=e.value,f=e.visited,d=c===o,v=n||s;return{active:i,blur:t,change:r,dirty:!d,error:n,focus:a,initial:o,invalid:v,name:u,pristine:d,submitError:s,touched:l,valid:!v,value:c,visited:f}};e.createForm=function(e){if(!e)throw new Error("No config specified");var r=e.initialValues,a=e.onSubmit,o=e.validate,s=e.debug;if(!a)throw new Error("No onSubmit function specified");var l={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirty:!1,initialValues:r&&u({},r),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:!1,values:r?u({},r):{}},lastFormState:void 0,validating:0},d=!1,v=function(e,i,t){var r=l.fields[e],n=r.validators,a=Object.keys(n),o=!1;if(a.length){var u=a.length;a.forEach(function(e){var a=function(e){(0==--u||!o&&e)&&(t(e),o=!0)};if(!o){var s=n[Number(e)],l=s(r.value,i,a);l&&S(l)?l.then(a,a):s.length<3&&a(l)}})}else t()},m=function(e){var i=l.fields,t=l.formState.values;l.validating++;var r=Object.keys(i);if(o){var a=function(a){l.error=a[p];var o=r.length,u=function(){0===o&&(l.validating--,e&&e())};r.length?r.forEach(function(e){v(e,t,function(t){var r=n(a,e);i[e].error=t||r,o--,u()})}):u()},u=o(t,a);u&&(S(u)?u.then(a,a):a(u))}else{var s=r.length,c=function(){0===s&&(l.validating--,e&&e())};s?r.forEach(function(e){v(e,t,function(t){i[e].error=t,s--,c()})}):c()}},j=function(e){if(!d){var i=l.fields,r=l.fieldSubscribers,n=l.formState;Object.keys(i).forEach(function(e){var a=i[e],o=f(n,a),u=a.lastFieldState;y(o,u)||(a.lastFieldState=o,t(r[e],o,u,b))})}},w=function(){return!l.error&&Object.keys(l.fields).every(function(e){return!l.fields[e].error&&!l.fields[e].submitError})},O=function(){return l.error||Object.keys(l.fields).some(function(e){return l.fields[e].error})},k=function(){var e=l.fields,i=l.formState,t=Object.keys(e).every(function(i){return e[i].value===e[i].initial}),r=w(),n=l.validating>0;if(t===i.pristine&&r===i.valid&&n===i.validating&&l.error===i.error&&l.lastFormState&&l.lastFormState.values===i.values&&l.lastFormState.active===i.active)return l.lastFormState;var a=i.active,o=i.initialValues,u=i.submitting,s=i.submitError,c=i.submitFailed,f=i.submitSucceeded,d=i.values;return{active:a,dirty:!t,error:l.error,initialValues:o,invalid:!r,pristine:t,submitting:u,submitError:s,submitFailed:c,submitSucceeded:f,valid:r,validating:n,values:d}},N=function(){return s&&!1&&s(E(l.formState),Object.keys(l.fields).reduce(function(e,i){return e[i]=F(l.fields[i]),e},{}))},A=function(){if(N(),!d){var e=l.lastFormState,i=k();i!==e&&(l.lastFormState=i,t(l.subscribers,i,e,h))}};m();var V={batch:function(e){d=!0,e(),d=!1,j(),A()},blur:function(e){var i=l.fields,t=l.formState,r=i[e];r&&r.active&&(delete t.active,i[e]=u({},r,{active:!1,touched:!0}),j(),A())},change:function(e,i){var t=l.fields;t[e]&&t[e].value!==i&&(t[e].value=i,l.formState.values=c(l.formState.values,e,i)||{},j(),A(),m(function(){j(),A()}))},focus:function(e){var i=l.fields[e];i&&!i.active&&(l.formState.active=e,i.active=!0,i.visited=!0,j(),A())},getState:function(){return E(l.formState)},initialize:function(e){var i=l.fields,t=l.formState;t.initialValues=e,t.values=e,Object.keys(i).forEach(function(t){var r=i[t],a=n(e,t);r.value=a,r.initial=a,r.touched=!1,r.visited=!1}),m(function(){j(),A()})},registerField:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments[3];l.fieldSubscribers[e]||(l.fieldSubscribers[e]={index:0,entries:{}});var o=l.fieldSubscribers[e].index++;if(l.fieldSubscribers[e].entries[o]={subscriber:g(t),subscription:r},!l.fields[e]){var u=l.formState.initialValues?n(l.formState.initialValues,e):void 0;l.fields[e]={active:!1,blur:function(){return V.blur(e)},change:function(i){return V.change(e,i)},focus:function(){return V.focus(e)},initial:u,lastFieldState:void 0,name:e,touched:!1,value:u,validators:{},visited:!1}}a&&(l.fields[e].validators[o]=a);var s=!1,c=function(){var n=f(l.formState,l.fields[e]);i(t,r,n,void 0,b,!0),l.fields[e].lastFieldState=n,s=!0},d=!1;return m(function(){A(),s||c(),j(),d=!0}),d||c(),function(){delete l.fields[e].validators[o],delete l.fieldSubscribers[e].entries[o],Object.keys(l.fieldSubscribers[e].entries).length||(delete l.fieldSubscribers[e],delete l.fields[e]),m(function(){j(),A()})}},reset:function(){V.initialize(l.formState.initialValues||{})},submit:function(){var e=l.formState,i=l.fields;if(!O()){var t=void 0,r=!1,o=function(a){e.submitting=!1,a&&Object.keys(a).length?(e.submitFailed=!0,e.submitSucceeded=!1,Object.keys(i).forEach(function(e){i[e].submitError=a&&n(a,e)}),e.submitError=a[p]):(Object.keys(i).forEach(function(e){delete i[e].submitError}),delete e.submitError,e.submitFailed=!1,e.submitSucceeded=!0),A(),j(),r=!0,t&&t()};if(e.submitting=!0,e.submitFailed=!1,e.submitSucceeded=!1,2===a.length){if(a(e.values,o),!r)return A(),new Promise(function(e){t=e})}else{var u=a(e.values);if(u&&S(u))return A(),u.then(o);o(u)}}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var r=g(e),n=l.formState,a=l.subscribers,o=a.index++;a.entries[o]={subscriber:r,subscription:t};var s=!l.error,c=u({},n,{error:l.error,invalid:!s,valid:s});return i(r,t,c,c,h,!0),function(){delete a.entries[o]}}};return V},e.FORM_ERROR=p,e.version="0.0.2",e.formSubscriptionItems=m,e.fieldSubscriptionItems=d,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(e["final-form"]={})}(this,function(e){"use strict";function i(e,i,t,r,n){var o=n(t,r,i,arguments.length>5&&void 0!==arguments[5]&&arguments[5]);o&&e(o)}function t(e,t,r,n){var o=e.entries;Object.keys(o).forEach(function(e){var a=o[Number(e)],u=a.subscription;i(a.subscriber,u,t,r,n)})}var r=function(e){if(null===e||void 0===e)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.length?e.split(/[.[\]]+/).filter(Boolean):[]},n=function(e,i){var t=r(i),n=e,o=!0,a=!1,u=void 0;try{for(var s,l=t[Symbol.iterator]();!(o=(s=l.next()).done);o=!0){var c=s.value;if(void 0===n||null===n||!isNaN(n))return;if(Array.isArray(n)&&isNaN(c))return;n=n[c]}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}return n},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e},u=Object.assign||function(e){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},s=function(e){if(Array.isArray(e)){for(var i=0,t=Array(e.length);i<e.length;i++)t[i]=e[i];return t}return Array.from(e)},l=function e(i,t,r,n){if(t>=r.length)return n;var o=r[t];if(isNaN(o)){if(void 0===i||null===i){var l=e(void 0,t+1,r,n);return void 0===l?void 0:a({},o,l)}if(Array.isArray(i))throw new Error("Cannot set a non-numeric property on an array");var c=e(i[o],t+1,r,n),f=Object.keys(i).length;return void 0===c&&(void 0===i[o]&&0===f||void 0!==i[o]&&f<=1)?void 0:u({},i,a({},o,c))}var d=Number(o);if(void 0===i||null===i){var v=e(void 0,t+1,r,n);if(void 0===v)return;var b=[];return b[d]=v,b}if(!Array.isArray(i))throw new Error("Cannot set a numeric property on an object");var m=i[d],y=e(m,t+1,r,n);if(void 0!==y||!(void 0===m&&0===i.length||void 0!==m&&1===i.length)){var h=[].concat(s(i));return void 0===y?h.splice(d,1):h[d]=y,h}},c=function(e,i,t){if(void 0===e||null===e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(void 0===i||null===i)throw new Error("Cannot call setIn() with "+String(i)+" key");return l(e,0,r(i),t)},f=function(e,i){var t=e.submitFailed,r=e.submitSucceeded,n=i.active,o=i.blur,a=i.change,u=i.error,s=i.focus,l=i.initial,c=i.name,f=i.submitError,d=i.touched,v=i.value,b=i.visited,m=l===v,y=!u&&!f;return{active:n,blur:o,change:a,dirty:!m,error:u,focus:s,initial:l,invalid:!y,name:c,pristine:m,submitError:f,submitFailed:t,submitSucceeded:r,touched:d,valid:y,value:v,visited:b}},d=["active","dirty","error","initial","invalid","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],v=function(e,i,t,r,n){var o=!1;return n.forEach(function(n){r[n]&&(e[n]=i[n],t&&i[n]===t[n]||(o=!0))}),o},b=function(e,i,t,r){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return v(n,e,i,t,d)||!i||r?n:void 0},m=["active","dirty","error","initialValues","invalid","pristine","submitting","submitError","submitFailed","submitSucceeded","valid","validating","values"],y=function(e,i,t,r){var n={};return v(n,e,i,t,m)||!i||r?n:void 0},h=function(e,i){if(e===i)return!0;if("object"!==(void 0===e?"undefined":o(e))||!e||"object"!==(void 0===i?"undefined":o(i))||!i)return!1;var t=Object.keys(e),r=Object.keys(i);if(t.length!==r.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(i),a=0;a<t.length;a++){var u=t[a];if(!n(u)||e[u]!==i[u])return!1}return!0},S=function(e){var i=void 0,t=void 0;return function(){for(var r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return i&&n.length===i.length&&!n.some(function(e,t){return!h(i[t],e)})||(i=n,t=e.apply(void 0,n)),t}},g=function(e){return!!e&&("object"===(void 0===e?"undefined":o(e))||"function"==typeof e)&&"function"==typeof e.then},p=Symbol("form-error"),E=function(e){return{active:e.active,dirty:e.dirty,error:e.error,invalid:e.invalid,initialValues:e.initialValues,pristine:e.pristine,submitting:e.submitting,submitFailed:e.submitFailed,submitSucceeded:e.submitSucceeded,submitError:e.submitError,valid:e.valid,validating:e.validating,values:e.values}},j=function(e){var i=e.active,t=e.blur,r=e.change,n=e.error,o=e.focus,a=e.initial,u=(e.lastFieldState,e.name),s=e.submitError,l=e.touched,c=e.value,f=e.visited,d=c===a,v=n||s;return{active:i,blur:t,change:r,dirty:!d,error:n,focus:o,initial:a,invalid:v,name:u,pristine:d,submitError:s,touched:l,valid:!v,value:c,visited:f}};e.createForm=function(e){if(!e)throw new Error("No config specified");var r=e.debug,o=e.initialValues,a=e.onSubmit,l=e.validate,d=e.validateOnBlur;if(!a)throw new Error("No onSubmit function specified");var v={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirty:!1,initialValues:o&&u({},o),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:!1,values:o?u({},o):{}},lastFormState:void 0,validating:0},m=!1,O=function(e){var i=[];if(l){var t=function(i){v.error=i[p],Object.keys(v.fields).forEach(function(t){e(t,n(i,t))})},r=l(v.formState.values);g(r)?i.push(r.then(t)):t(r)}return i},F=function(e,i){var t=e.validators,r=[];if(Object.keys(t).length){var n=void 0;Object.keys(t).forEach(function(o){var a=(0,t[Number(o)])(e.value,v.formState.values);a&&g(a)?r.push(a.then(i)):n||(n=a)}),i(n)}return r},w=function(e){var i=v.fields,t=Object.keys(i);if(l||t.some(function(e){return i[e].validators&&Object.keys(i[e].validators).length})){var r={},n={},o=function(e,i){r[e]=i},a=function(e,i){n[e]=i},u=[].concat(s(O(function(e,i){return o(e,i)})),s(t.reduce(function(e,t){return[].concat(s(e),s(F(i[t],function(e){return a(t,e)})))},[])));t.forEach(function(e){i[e].error=n[e]||r[e]}),u.length?(v.validating++,e&&e(),o=a=function(e,t){i[e].error=t},Promise.all(u).then(function(){v.validating--,e&&e()})):e&&e()}else e&&e()},k=function(e){if(!m){var i=v.fields,r=v.fieldSubscribers,n=v.formState;Object.keys(i).forEach(function(e){var o=i[e],a=f(n,o),u=o.lastFieldState;h(a,u)||(o.lastFieldState=a,t(r[e],a,u,b))})}},N=function(){return!v.error&&Object.keys(v.fields).every(function(e){return!v.fields[e].error&&!v.fields[e].submitError})},A=function(){return v.error||Object.keys(v.fields).some(function(e){return v.fields[e].error})},V=function(){var e=v.fields,i=v.formState,t=Object.keys(e).every(function(i){return e[i].value===e[i].initial}),r=N(),n=v.validating>0;if(t===i.pristine&&r===i.valid&&v.error===i.error&&v.lastFormState&&v.lastFormState.validating===n&&v.lastFormState.values===i.values&&v.lastFormState.active===i.active)return v.lastFormState;var o=i.active,a=i.initialValues,u=i.submitting,s=i.submitError,l=i.submitFailed,c=i.submitSucceeded,f=i.values;return{active:o,dirty:!t,error:v.error,initialValues:a,invalid:!r,pristine:t,submitting:u,submitError:s,submitFailed:l,submitSucceeded:c,valid:r,validating:n,values:f}},x=function(){return r&&!1&&r(E(v.formState),Object.keys(v.fields).reduce(function(e,i){return e[i]=j(v.fields[i]),e},{}))},P=function(){if(x(),!m){var e=v.lastFormState,i=V();i!==e&&(v.lastFormState=i,t(v.subscribers,i,e,y))}};w();var C={batch:function(e){m=!0,e(),m=!1,k(),P()},blur:function(e){var i=v.fields,t=v.formState,r=i[e];r&&r.active&&(delete t.active,i[e]=u({},r,{active:!1,touched:!0}),d?w(function(){k(),P()}):(k(),P()))},change:function(e,i){var t=v.fields;t[e]&&t[e].value!==i&&(t[e].value=i,v.formState.values=c(v.formState.values,e,i)||{},k(),P(),d?(k(),P()):w(function(){k(),P()}))},focus:function(e){var i=v.fields[e];i&&!i.active&&(v.formState.active=e,i.active=!0,i.visited=!0,k(),P())},getState:function(){return E(v.formState)},initialize:function(e){var i=v.fields,t=v.formState;t.initialValues=e,t.values=e,Object.keys(i).forEach(function(t){var r=i[t],o=n(e,t);r.value=o,r.initial=o,r.touched=!1,r.visited=!1}),w(function(){k(),P()})},registerField:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments[3];v.fieldSubscribers[e]||(v.fieldSubscribers[e]={index:0,entries:{}});var a=v.fieldSubscribers[e].index++;if(v.fieldSubscribers[e].entries[a]={subscriber:S(t),subscription:r},!v.fields[e]){var u=v.formState.initialValues?n(v.formState.initialValues,e):void 0;v.fields[e]={active:!1,blur:function(){return C.blur(e)},change:function(i){return C.change(e,i)},focus:function(){return C.focus(e)},initial:u,lastFieldState:void 0,name:e,touched:!1,value:u,validators:{},visited:!1}}o&&(v.fields[e].validators[a]=o);var s=!1,l=function(){var n=f(v.formState,v.fields[e]);i(t,r,n,void 0,b,!0),v.fields[e].lastFieldState=n,s=!0};return w(function(){P(),s||l(),k()}),function(){delete v.fields[e].validators[a],delete v.fieldSubscribers[e].entries[a],Object.keys(v.fieldSubscribers[e].entries).length||(delete v.fieldSubscribers[e],delete v.fields[e]),w(function(){k(),P()})}},reset:function(){C.initialize(v.formState.initialValues||{})},submit:function(){var e=v.formState,i=v.fields;if(A())return Object.keys(i).forEach(function(e){i[e].touched=!0}),void k();var t=void 0,r=!1,o=function(o){e.submitting=!1,o&&Object.keys(o).length?(e.submitFailed=!0,e.submitSucceeded=!1,Object.keys(i).forEach(function(e){i[e].submitError=o&&n(o,e)}),e.submitError=o[p]):(Object.keys(i).forEach(function(e){delete i[e].submitError}),delete e.submitError,e.submitFailed=!1,e.submitSucceeded=!0),P(),k(),r=!0,t&&t()};if(e.submitting=!0,e.submitFailed=!1,e.submitSucceeded=!1,2===a.length){if(a(e.values,o),!r)return P(),new Promise(function(e){t=e})}else{var u=a(e.values);if(u&&g(u))return P(),u.then(o);o(u)}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var r=S(e),n=v.formState,o=v.subscribers,a=o.index++;o.entries[a]={subscriber:r,subscription:t};var s=!v.error,l=u({},n,{error:v.error,invalid:!s,valid:s});return i(r,t,l,l,y,!0),function(){delete o.entries[a]}}};return C},e.FORM_ERROR=p,e.version="0.0.2",e.formSubscriptionItems=m,e.fieldSubscriptionItems=d,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=final-form.umd.min.js.map
{
"name": "final-form",
"version": "0.0.2",
"description": "🏁 Framework agnostic, high performance, subscription-based form state management",
"version": "0.0.3",
"description":
"🏁 Framework agnostic, high performance, subscription-based form state management",
"main": "dist/final-form.cjs.js",
"jsnext:main": "dist/final-form.es.js",
"module": "dist/final-form.es.js",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {

@@ -16,3 +15,4 @@ "start": "nps",

},
"author": "Erik Rasmussen <rasmussenerik@gmail.com> (http://github.com/erikras)",
"author":
"Erik Rasmussen <rasmussenerik@gmail.com> (http://github.com/erikras)",
"license": "MIT",

@@ -61,6 +61,3 @@ "repository": {

"lint-staged": {
"*.{js,json,md,css}": [
"prettier --write",
"git add"
]
"*.{js,json,md,css}": ["prettier --write", "git add"]
},

@@ -67,0 +64,0 @@ "bundlesize": [

@@ -11,3 +11,3 @@ # 🏁 Final Form

✅ 💥 **3.42k gzipped** 💥
✅ 💥 **3.50k gzipped** 💥

@@ -96,4 +96,5 @@ ---

* [`onSubmit: (values: Object, callback: ?(errors: ?Object) => void) => ?Object | Promise<?Object>`](#onsubmit-values-object-callback-errors-object--void--object--promiseobject)
* [`validate?: (values: Object, callback: ?(errors: Object) => void) => Object | void`](#validate-values-object-callback-errors-object--void--object--void)
* [`validate?: (values: Object) => void) => Object | Promise<Object>`](#validate-values-object--void--object--promiseobject)
* [`debug?: (state: FormState, fieldStates: { [string]: FieldState }) => void`](#debug-state-formstate-fieldstates--string-fieldstate---void)
* [`validateOnBlur?: boolean`](#validateonblur-boolean)
* [`FieldState`](#fieldstate)

@@ -139,3 +140,3 @@ * [`active?: boolean`](#active-boolean)

* [`subscribe: (subscriber: FormSubscriber, subscription: FormSubscription) => Unsubscribe`](#subscribe-subscriber-formsubscriber-subscription-formsubscription--unsubscribe)
* [`registerField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object)) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-validate-value-any-allvalues-object--unsubscribe)
* [`registerField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object) => any | Promise<any>) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-validate-value-any-allvalues-object--any--promiseany--unsubscribe)
* [`reset: () => void`](#reset---void)

@@ -229,3 +230,3 @@ * [`FormState`](#formstate)

#### `validate?: (values: Object, callback: ?(errors: Object) => void) => Object | void`
#### `validate?: (values: Object) => void) => Object | Promise<Object>`

@@ -238,4 +239,2 @@ A whole-record validation function that takes all the values of the form and

`Object` of validation errors when the values are invalid.
* Asynchronously with a callback: returns `undefined`, calls `callback()` with
no arguments on success, or with an `Object` of validation errors on failure.
* Asynchronously with a `Promise`: returns a `Promise<?Object>` that resolves

@@ -256,2 +255,7 @@ with no value on success or _resolves_ with an `Object` of validation errors

#### `validateOnBlur?: boolean`
If `true`, validation will happen on blur. If `false`, validation will happen on
change. Defaults to `false`.
### `FieldState`

@@ -443,3 +447,3 @@

#### `registerField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object)) => Unsubscribe`
#### `registerField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object) => any | Promise<any>) => Unsubscribe`

@@ -450,2 +454,7 @@ Registers a new field and subscribes to changes to it. **The `subscriber` will

This is also where you may provide an optional field-level validation function
that should return `undefined` if the value is valid, or an error. It can
optionally return a `Promise` that _resolves_ (not rejects) to `undefined` or an
error.
#### `reset: () => void`

@@ -452,0 +461,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc