File tree 2 files changed +5
-6
lines changed
2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export type RuleObject = {
12
12
/**
13
13
* Returns whether the rule passed with the given element(s)
14
14
*/
15
- passed ( elements : HTMLElement [ ] , ...args : string [ ] ) : boolean ;
15
+ passed ( elements : HTMLElement [ ] , ...args : string [ ] ) : boolean | Promise < void > ;
16
16
/**
17
17
* Message shown when the rule doesn't pass
18
18
*/
Original file line number Diff line number Diff line change @@ -105,14 +105,13 @@ export class Validator {
105
105
/**
106
106
* Validate the elements
107
107
*/
108
- public validate ( ) : boolean {
108
+ public async validate ( ) : Promise < boolean > {
109
109
this . errors = [ ] ;
110
110
111
111
if ( this . hasValidatableElements ( ) ) {
112
- return ! this . getRuleList ( )
113
- . map ( ( rule : string ) => this . validateRule ( rule ) )
112
+ return ! ( await Promise . all ( this . getRuleList ( ) . map ( ( rule : string ) => this . validateRule ( rule ) ) ) )
114
113
. filter ( ( passed : boolean ) => ! passed )
115
- . length ;
114
+ . length
116
115
}
117
116
118
117
return true ;
@@ -128,7 +127,7 @@ export class Validator {
128
127
/**
129
128
* Validate a specific rule
130
129
*/
131
- private validateRule ( rule : string ) : boolean {
130
+ private async validateRule ( rule : string ) : Promise < boolean > {
132
131
const [ ruleName , ruleArgs = '' ] = rule . split ( ':' ) ;
133
132
134
133
if ( Validator . ruleExists ( ruleName ) ) {
You can’t perform that action at this time.
0 commit comments