Skip to content

Commit 25d1d12

Browse files
committed
fixed bug: error message was not removed on validator-required='true'
1 parent e340f63 commit 25d1d12

3 files changed

Lines changed: 41 additions & 22 deletions

File tree

dist/angular-validator.js

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-validator.min.js

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directive.coffee

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ validator = ($injector) ->
3030
oldValue: the old value of $watch
3131
###
3232
successCount = 0
33+
increaseSuccessCount = ->
34+
if ++successCount is rules.length
35+
rule.success scope, element, attrs for rule in rules
36+
args.success?()
37+
return
38+
3339
for rule in rules
3440
switch from
3541
when 'blur'
3642
continue if rule.invoke isnt 'blur'
3743
rule.enableError = yes
38-
when 'watch' then continue if rule.invoke isnt 'watch' and not rule.enableError
44+
when 'watch'
45+
if rule.invoke isnt 'watch' and not rule.enableError
46+
increaseSuccessCount()
47+
continue
3948
when 'broadcast' then rule.enableError = yes
4049
else
4150

@@ -49,9 +58,7 @@ validator = ($injector) ->
4958
# validate
5059
rule.validator model(scope), scope, element, attrs,
5160
success: ->
52-
if ++successCount is rules.length
53-
rule.success scope, element, attrs
54-
args.success?()
61+
increaseSuccessCount()
5562
error: ->
5663
rule.error scope, element, attrs if rule.enableError
5764
if args.error?() is 1
@@ -70,6 +77,7 @@ validator = ($injector) ->
7077
Remove the rule in rules by the name.
7178
###
7279
for index in [0...rules.length] by 1 when rules[index]?.name is name
80+
rules[index].success scope, element, attrs
7381
rules.splice index, 1
7482
index--
7583

0 commit comments

Comments
 (0)