MCPcopy
hub / github.com/thinkjs/thinkjs / __after

Function __after

lib/extend/logic.js:48–76  ·  view source on GitHub ↗

* after magic method

()

Source from the content-addressed store, hash-verified

46 * after magic method
47 */
48 __after() {
49 // This will be removed in the future (>think-logic@1.2.0)
50 // check request method is allowed
51 let allowMethods = this.allowMethods;
52 if (!helper.isEmpty(allowMethods)) {
53 if (helper.isString(allowMethods)) {
54 allowMethods = allowMethods.split(',').map(e => {
55 return e.toUpperCase();
56 });
57 }
58 const method = this.method;
59 if (allowMethods.indexOf(method) === -1) {
60 this.fail(this.config('validateDefaultErrno'), 'METHOD_NOT_ALLOWED');
61 return false;
62 }
63 }
64
65 // check rules
66 if (!this[INVOKED]) {
67 this.rules = this.getCombineRules(this.scope, this.rules);
68 if (!helper.isEmpty(this.rules)) {
69 const flag = this.validate(this.rules);
70 if (!flag) {
71 this.fail(this.config('validateDefaultErrno'), this.validateErrors);
72 return false;
73 }
74 }
75 }
76 }
77};

Callers

nothing calls this directly

Calls 3

configMethod · 0.80
failMethod · 0.65
validateMethod · 0.65

Tested by

no test coverage detected