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
The User can able to return validation config conditionally #142
Comments
Why excepts conditionalExpression ? Maybe, we could need to change the funtion. If it is not causing some problem, maybe we can keep it. |
dynamicConfig function should have this format dynamicConfig(currentFormGroup: formGroupValue, rootFormGroup: formGroupValue, C) Partial |
There are lots of things we have to take care in the framework if we provide a conditionalExpression in the 'dynamicConfig'. I believe everything can be possible with the conditionalExpression. Let's release without the conditionalExpression, latter on If we have a solid case for putting the conditionalExpression inside the dynamicConfig, then we will include the same. Make sense? |
As current and root is the FormGroup value as per the respective node(parent FormGroup and root FormGroup value). What's C(the third parameter)? |
@manudss I am planning to release the new version tonight and waiting for your inputs. |
The third parameters should be the current config object. And C was the generic types. As I have shown before. dynamicConfig(parent: { [key: string]: any }, root: { [key: string]: any }, currentConfig: C): Partial |
But why currentConfig is required, as every time it has been changed and as per the current implemented code, I haven't maintained the original state of the config object. I would like to understand the scenario where this will be helpful. |
ok, if you didn't maintenaned a state of config. It was juste if we would like to have the already defined config. |
Thanks for your inputs. this.userFormGroup = this.formBuilder.group({
isRugby:false,
games:['',RxwebValidators.allOf(
{
matchValues:['Cricket','Chess'],
dynamicConfig:(x,y,c)=> {
if(x.isRugby)
c.matchValues.push('Rugby');
else
/// something else...
return c;
}
})]
}) Looks promising of current config. I will try to add this as well in our release. |
yes, it is for some case like this, that currentConfig should be usefull. or to keep the min value exemple. If in dynamicConfig, we would like in some case to add + 10 to the current Min Value. (or compute the default config with number of another fields). |
@manudss I have transformed the earlier provided compose validator code with the minNumber validator through 'dynamicConfig'. Please refer the stackblitz example. Feel free to share your comments for the same. |
Perfect, it was a cleanest and powerful way to make conditional validation.
Thanks for your work.
Le jeu. 14 mars 2019 à 02:54, Ajay Ojha <notifications@github.com> a écrit :
… @manudss <https://github.com/manudss> I have transformed the earlier
provided compose validator code with the minNumber validator through
'dynamicConfig'. Please refer the stackblitz example
<https://stackblitz.com/edit/angular-rxweb-compose-validator-with-required-validation-xrutmz?file=src%2Fapp%2Fcompose-add.component.ts>
.
Feel free to share your comments for the same.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#142 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA_5FuWJ9W0-xjafZXisyDXrHQWqs3D2ks5vWavegaJpZM4bo3NY>
.
|
Description
The user can able to return the validation config conditionally as needed. As discussed with @manudss on gitter. It should work by providing a new property of 'dynamicConfig' which returns the validation config. This will help when some of the calculation is required based upon the cross field value or current control value.
Describe the solution you'd like
The expected solution should be like as below :
As per the above code in the minNumber validation user can able to return the properties which are available in the NumberConfig interface excepts conditionalExpression.
The text was updated successfully, but these errors were encountered: