Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Bug in validation service addValidator function #153

Closed
mandarranade opened this issue Apr 20, 2017 · 6 comments
Closed

Bug in validation service addValidator function #153

mandarranade opened this issue Apr 20, 2017 · 6 comments

Comments

@mandarranade
Copy link

mandarranade commented Apr 20, 2017

Hi There is an issue with addValidator function which resides under ValidationService. In Case of validateOnEmpty : true option set in global option code fails at
_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

Instead of above line it should have been

_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

The commonObj resides inside self in that function hence if we directly access it, it ends up failing the code.
[edit : fixed bad language]

@mandarranade mandarranade changed the title Bug in validation addValidator function Bug in validation service addValidator function Apr 20, 2017
@ghiscoding
Copy link
Owner

ghiscoding commented Apr 20, 2017

have you tried it?

Ah actually, I see what you mean now. Will update soon after running all tests during lunch. Thanks

@mandarranade
Copy link
Author

Hi thanks for replying on the issue instantly. I was actually using library for some validation scenario where I don't need required validation but instead I need to call a custom validation. After digging into documentation I found out about validateOnEmpty flag. When I tried to use it in my implementation it failed. As we don't have a non minified version in dist folder I manually copied all JS files and created non minified version. Earlier I thought it had something to do with my wrong implementation but later I realize code is failing at the line which I mentioned above. Two three lines below you have accessed commonObj from self. Replacing the line with the self.commonObj worked fine. I am not very sure about the impact it is going to cause. But I thought would let you know. Your work is awesome! Just one request if possible please have a minified and non minified version in dist folder. It would be great.

@ghiscoding
Copy link
Owner

The minified is just a bundle of what is in src folder, you can use them directly (just make sure to import the Directive first then the other files), this is commented out in the example but you can use it like this:

<script type="text/javascript" src="src/validation-directive.js"></script>
<script type="text/javascript" src="src/validation-service.js"></script>
<script type="text/javascript" src="src/validation-common.js"></script>
<script type="text/javascript" src="src/validation-rules.js"></script>

@ghiscoding
Copy link
Owner

Actually that's a good idea and easy to modify the Gulp, I added it. A new version 1.5.20 just got pushed (you're lucky I'll be away for the next 3 weeks).

@mandarranade
Copy link
Author

Thanks @ghiscoding . It was way faster than I would have imagined. And also thanks for adding non-minified version too.

@ghiscoding
Copy link
Owner

It was easier since you provided the code to change, cheers for that ;)

Also, if you like it and haven't clicked on the ⭐ yet, then please do so as it's also nice to see the counter going up :) Thanks for providing the code.

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

No branches or pull requests

2 participants