• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

express-validator / express-validator / 4335261413

pending completion
4335261413

Pull #1216

github

GitHub
Merge 4d898a74a into 6c6ea73b7
Pull Request #1216: Add globstar (wildcard deep matching) support

401 of 410 branches covered (97.8%)

26 of 26 new or added lines in 1 file covered. (100.0%)

624 of 624 relevant lines covered (100.0%)

421.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/context-items/custom-validation.ts
1
import { CustomValidator, Meta } from '../base';
2
import { Context } from '../context';
3
import { ContextItem } from './context-item';
4

5
export class CustomValidation implements ContextItem {
33✔
6
  message: any;
7

8
  constructor(private readonly validator: CustomValidator, private readonly negated: boolean) {}
192✔
9

10
  async run(context: Context, value: any, meta: Meta) {
11
    try {
315✔
12
      const result = this.validator(value, meta);
315✔
13
      const actualResult = await result;
303✔
14
      const isPromise = result && result.then;
294✔
15
      const failed = this.negated ? actualResult : !actualResult;
294✔
16

17
      // A promise that was resolved only adds an error if negated.
18
      // Otherwise it always suceeds
19
      if ((!isPromise && failed) || (isPromise && this.negated)) {
294✔
20
        context.addError({ type: 'field', message: this.message, value, meta });
159✔
21
      }
22
    } catch (err) {
23
      if (this.negated) {
21✔
24
        return;
6✔
25
      }
26

27
      context.addError({
15✔
28
        type: 'field',
29
        message: this.message || (err instanceof Error ? err.message : err),
33✔
30
        value,
31
        meta,
32
      });
33
    }
34
  }
35
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc