Files
Tom MoorandClaude Fable 5.1 a577d5c2c8 fix: Validate API key and OAuth scopes at the model layer (#13664)
* fix: Validate API key scopes with Sequelize-level validators

* test: Add API regression tests for duplicate OAuth redirect URIs

* fix: Preserve wildcard scope and guard non-string redirect URIs

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 23:10:32 -04:00

27 lines
626 B
TypeScript

import isURL from "validator/lib/isURL";
import { addAttributeOptions } from "sequelize-typescript";
/**
* A decorator that validates that a string is a url or relative path.
*/
export default function IsUrlOrRelativePath(
target: object,
propertyName: string
) {
return addAttributeOptions(target, propertyName, {
validate: {
validUrlOrPath(value: string) {
if (
value &&
!isURL(value, {
require_host: false,
require_protocol: false,
})
) {
throw new Error("Must be a URL or relative path");
}
},
},
});
}