-
Notifications
You must be signed in to change notification settings - Fork 24
Refactor to use functional paradigm #250
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
Conversation
UpdateI am currently working on validation types. Trying to unify them, make their declaration more clear. Changelog
I am experiencing a weird issue during Update: That pending promise was cause because I made the reducer function in |
ff97d63
to
f48e5fb
Compare
Currently still experiencing that unnecessary validation issue. May be related to wrong handling of Update: Solved that by explicitly returning if (!validationResult) {
return;
} |
12939fb
to
4459413
Compare
…solverArgs" in validator functions
UpdateInvestigating on the combined validation scenario, and the issue that async validation is triggering after sync invalid field, which results into distorted validation result. To understand the issue, it's important to understand the chain of actions affecting the validation:
The reason for combined validation not working is unnecessary sync validation triggered by onBlur. SolutionMy previous assumption of unnecessary const validSync = ({ fieldProps }) => {
return fieldProps.validatedSync ? fieldProps.validSync : true
} This way async validation relies on the reflected validation result. Even when sync returns explicit |
Okay, I am experiencing a weird issue with Cypress typing into inputs again. Sometimes it types everything except the first letter. That, obviously, fails the test, which expects the value match. At the moment this randomly fails "Combined validations" scenario. When that scenario is run alone, it passes always. That makes me thinking that it may be an issue with accumulation of scenario calls. Maybe some load or something. Possible on both form and Cypress levels. I usually play with timeouts to eliminate overload issues, so that may be a good place to start. |
Update on AJAX pre-filling scenarioI have analyzed the issue and conclude that the reason was due to concurrent state updates. There are two fields which get the same controlled value upon some async operation. Each value change fires:
Concurrency comes in That was caused due to the following dispatch of appropriateValidate({
chain: [validateSync],
fieldProps: updatedFieldProps,
form
}) The issue with this, is that in case of debounced validation At the moment, I haven't touched this concurrency issue, but have changed the logic of I do understand that concurrent state updates must be dealt with, but haven't come up with a stable solution for that. |
I will try to fix unstable typing issue in Cypress by doing the following:
|
Update
const fields = args.fields || args.form.state.fields I will see how that affects the tests, since it, essentially, is the same as specifying the |
97f769a
to
eda06d8
Compare
eda06d8
to
7dfce0a
Compare
Overview
What
This pull request introduces changes that refine the existing architecture to use a more functional approach. By the latter I mean a preference for small pure functions, which can be easily swapped or reused.
Why
Roadmap
Architecture
parallel
,seq
)Immutable.Record
to handle field record instead of manual composition increateField
recordUtils
to complexly handle field interactions (i.e.handleFieldChange
), to be used by the formless fieldsForm.validateField
into a pure functionValidation
ValidationType
classValidationType.shouldValidate()
Validation messages
getMessages
intovalidateAndReflect
Misc
getRxProps
according to the updated field Record29.04
applyFormRules
to the top-level validation resultshouldValidate
smarted:types
argument optional forvalidateByType
function. When it's not provided, callgetNecessaryValidationTypes
on the givenfieldProps
, and build a validators sequence based on the received validation types array.types
when usingForm.validateField()
by default, so that the changes above get place (automatic determining of the necessary validation types)05.05
camelize
createSeq
debounce
dispatch
enforceArray
getComponentName
flushFieldRefs
flattenDeep
isset
recordUtils
makeCancellable
recordUtils.createField
figure out howinitialValue
is set. Whether on usage level, or class level.07.05
types
propagation toreflectValidationResult
. I do not like howvalidate
returns both validation result and types being applied.08.05
force
parameter. Need to addforce
logic support to validation algorithm.12.05
ruleKeyPath
to a rule and rejected rule to make getting error messages easiertypes
as a parameter tovalidate
functionforce
to force any provided validatorsvalidate
andreflectValidation
methodvalidator
function when no validation is neededcheckRequiredEmpty
validator and integrate it intovalidateSync
chain!value && !required
as a part ofshouldValidateSync()
applyFormRules
handle call when no rules are presentapplyFormRules
compose funcs based on which rules are present19.05
expected
totrue
either.22.05
reduceResults
andreduceResultsWhile
shouldValidateX
is necessary when we have dynamic rules list composition vialistOf(addWhen)
27.05
Form.submit()
to be prevented if there are any unexpected fieldsdebounceTime
" integration test case. That one is broken because validation behavior was changed and now the field's validity props are reset on each change. I think that affects when debounce is fired.8.06
16.06
23.06
Asynchronous validation
validateAsync
into default validator chainvalidateAsync
being the last entry in the validation chain, if proves unnecessary (or falsely returnstrue
when it shouldn't) it makes the field expected, when it shouldn't be (take interdependent rxprops scenario) (3ed6df5, 79adaed)Misc
Propagate "validating" state during the field blur once the validation occurred (have intermediate fields update)Declined for now. Should be introduced as a separate new feature.Functional
Cannot read property "getIn" of undefined
.Final