MCPcopy
hub / github.com/NginxProxyManager/nginx-proxy-manager / validator

Function validator

backend/lib/validator/index.js:23–43  ·  view source on GitHub ↗
(schema, payload)

Source from the content-addressed store, hash-verified

21 * @returns {Promise}
22 */
23const validator = (schema, payload) => {
24 return new Promise((resolve, reject) => {
25 if (!payload) {
26 reject(new errs.InternalValidationError("Payload is falsy"));
27 } else {
28 try {
29 const validate = ajv.compile(schema);
30 const valid = validate(payload);
31
32 if (valid && !validate.errors) {
33 resolve(_.cloneDeep(payload));
34 } else {
35 const message = ajv.errorsText(validate.errors);
36 reject(new errs.InternalValidationError(message));
37 }
38 } catch (err) {
39 reject(err);
40 }
41 }
42 });
43};
44
45export default validator;

Callers 9

audit-log.jsFile · 0.85
users.jsFile · 0.85
settings.jsFile · 0.85
proxy_hosts.jsFile · 0.85
access_lists.jsFile · 0.85
streams.jsFile · 0.85
certificates.jsFile · 0.85
dead_hosts.jsFile · 0.85

Calls 1

validateFunction · 0.85

Tested by

no test coverage detected