Skip to content
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

FormValidatorFor - omf-required/omf-is-number not exposed as directive inputs #77

Open
PetterT2 opened this issue Jul 7, 2017 · 2 comments

Comments

@PetterT2
Copy link

PetterT2 commented Jul 7, 2017

To be able to use true/false pattern i.e. not have different html markup it would be nice with omf-required/omf-is-number as directive inputs

@khdi
Copy link
Contributor

khdi commented Jul 14, 2017

@PetterT2 Is this fixed in your custom validation directive?

@PetterT2
Copy link
Author

PetterT2 commented Jul 14, 2017

@khdi
Yes, all validation types has been exposed as inputs.
(The validator i supplied only needs some more testing of these validation-types i.e. isNumber, minValue/maxValue, minLength maxLength e.g. testing against arrays etc)

this should also be solved by thevalidator i sent:
#38

There is also a small sample attached showing the intended usage , including a custom validator function.

the thing not described in the sample is my thoughts about how to use it for components handling inputs of different types. I.e. a component intended to fill a specific data-model:

pseudocode:

----------Component TestExternalValidator view------------
<input [(ngModel)]="inputValue1"></input>
<ValueValidation [validator]="validatorPassedToComponentAsInput" [checkValue]="inputValue1" [isRequired]="true"></ValueValidation>
<input [(ngModel)]="inputValue2"></input>
<ValueValidation [validator]="validatorPassedToComponentAsInput" [checkValue]="inputValue2" [isRequired]="true"></ValueValidation>
<input [(ngModel)]="inputValue3"></input>
<ValueValidation [validator]="validatorPassedToComponentAsInput" [checkValue]="inputValue3" [isRequired]="true"></ValueValidation>

------------------------End----------------------------------------
--------------Component TestExternalValidator  -TS-------------------------------------

@Input("validator") validatorPassedToComponentAsInput: Validator = null;

public inputValue1: string = "";
...etc
---------------------------------------------------------------------

-----------User of component - view ---------------------------------
<div Validator #validatorToUse="Validator">

<--Will be validated on click below-->
<TestExternalValidator [Validator]=validatorToUse></TestExternalValidator >

<input [(ngModel)]="otherValue"></input>
<--Will be validated on click below-->
<ValueValidation [validator]="validatorToUse" [checkValue]="otherValue" [isRequired]="true"></ValueValidation>

<button type="button" class="btn btn-default btn-primary" [ValidatorTriggerFor]="validatorToUse" (validatedClick)="doSomethingOnValid(param1)" >Validate all including component now</button>

</div>
----------------------User of component - view - end----------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants