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

statuscompliance / status-backend / 14383613910

10 Apr 2025 02:54PM UTC coverage: 28.585% (+1.1%) from 27.524%
14383613910

Pull #112

github

web-flow
Merge f142de882 into e33452978
Pull Request #112: test(utils): added validation

135 of 606 branches covered (22.28%)

Branch coverage included in aggregate %.

6 of 8 new or added lines in 1 file covered. (75.0%)

1 existing line in 1 file now uncovered.

455 of 1458 relevant lines covered (31.21%)

2.27 hits per line

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

81.25
/src/middleware/validation.js
1
import { validate as isUUID } from 'uuid';
2

3
export const checkIdParam = (req, res, next) => {
7✔
4
  if (!req.params.id) return res.status(400).json({ error: 'Missing required parameter: id' });
2✔
5
  next();
1✔
6
};
7

8
export const validateUUID = (paramName) => {
7✔
9
  return (req, res, next) => {
105✔
10

11
    const paramValue = (req.params && req.params[paramName]) || (req.query && req.query[paramName]) || (req.body && req.body[paramName]);
7✔
12

13
    if (!paramValue) {
7✔
14
      return res.status(400).json({ error: `Missing parameter: ${paramName}` });
4✔
15
    }
16
    if (!isUUID(paramValue) && !isGrafanaUID(paramValue)) {
3✔
17
      return res.status(400).json({ error: `Invalid UUID for parameter: ${paramName}` });
1✔
18
    }
19
    next();
2✔
20
  };
21
};
22

23
export function validateParams(req, res, next, validation) {
NEW
24
  const errors = validation(req);
×
25

26
  if (!errors.isEmpty()) {
×
NEW
27
    return res.status(400).json({ 'errors': errors.array() });
×
28
  }
29

UNCOV
30
  next();
×
31
};
32

33
export function isGrafanaUID(uid) {
34
  return /^[a-zA-Z0-9]{12,24}$/.test(uid);
10✔
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

© 2026 Coveralls, Inc