| 59 | ) { |
| 60 | return { |
| 61 | async run( |
| 62 | validationConfig: PullRequestValidationConfig, |
| 63 | ...args: Parameters<T['assert']> |
| 64 | ): Promise<PullRequestValidationFailure | null> { |
| 65 | if (validationConfig[name]) { |
| 66 | const validation = new (getValidationCtor())( |
| 67 | name, |
| 68 | (message, isFinal = true) => |
| 69 | new PullRequestValidationFailure(message, name, canBeForceIgnored, isFinal), |
| 70 | ); |
| 71 | try { |
| 72 | await validation.assert(...args); |
| 73 | } catch (e) { |
| 74 | if (e instanceof PullRequestValidationFailure) { |
| 75 | return e; |
| 76 | } |
| 77 | throw e; |
| 78 | } |
| 79 | } |
| 80 | return null; |
| 81 | }, |
| 82 | }; |
| 83 | } |