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

panates / opra / 29494915195

16 Jul 2026 11:33AM UTC coverage: 83.024% (+0.4%) from 82.653%
29494915195

push

github

erayhanoglu
1.29.1

4118 of 5238 branches covered (78.62%)

Branch coverage included in aggregate %.

34348 of 41093 relevant lines covered (83.59%)

239.47 hits per line

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

84.93
/packages/common/src/document/data-type/primitive-types/string.type.ts
1
import { toString, type Validator, vg } from 'valgen';
1✔
2
import { DATATYPE_METADATA, DECODER, ENCODER } from '../../constants.js';
1✔
3
import { SimpleType } from '../simple-type.js';
1✔
4

1✔
5
@SimpleType({
1✔
6
  name: 'string',
1✔
7
  description: 'A sequence of characters',
1✔
8
  nameMappings: {
1✔
9
    js: 'string',
1✔
10
    json: 'string',
1✔
11
  },
1✔
12
})
1✔
13
export class StringType {
1✔
14
  constructor(properties?: Partial<StringType>) {
154!
15
    if (properties) Object.assign(this, properties);
1✔
16
  }
154✔
17

154✔
18
  @SimpleType.Attribute({
1✔
19
    description: 'Regex pattern to be used for validation',
1,918✔
20
  })
1,918✔
21
  pattern?: string | RegExp;
1,918✔
22

1✔
23
  @SimpleType.Attribute({
1✔
24
    description: 'Name of the pattern',
1!
25
  })
×
26
  patternName?: string;
×
27

×
28
  @SimpleType.Attribute({
×
29
    description: 'Minimum number of characters',
×
30
  })
×
31
  minLength?: number;
×
32

×
33
  @SimpleType.Attribute({
×
34
    description: 'Minimum number of characters',
1✔
35
  })
1✔
36
  maxLength?: number;
1✔
37

1✔
38
  protected [DECODER](properties: Partial<this>): Validator {
1,918✔
39
    const x: Validator[] = [];
1,918✔
40
    if (properties.pattern) {
1,918✔
41
      let formatName: string | undefined = properties.patternName;
1,918✔
42
      if (!formatName) {
1,918✔
43
        const meta = Reflect.getMetadata(
1,918✔
44
          DATATYPE_METADATA,
3✔
45
          Object.getPrototypeOf(this).constructor,
1,918✔
46
        );
1✔
47
        formatName = meta.name;
539✔
48
      }
539✔
49
      x.push(vg.matches(properties.pattern, { formatName }));
1✔
50
    }
1✔
51
    if (properties.minLength) x.push(vg.lengthMin(properties.minLength));
1✔
52
    if (properties.maxLength) x.push(vg.lengthMax(properties.maxLength));
1✔
53
    return x.length > 0
1✔
54
      ? vg.pipe([toString, ...x], { returnIndex: 0 })
1✔
55
      : toString;
1✔
56
  }
1✔
57

1✔
58
  protected [ENCODER](properties: Partial<this>): Validator {
1✔
59
    return this[DECODER](properties);
1✔
60
  }
1✔
61
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc