mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
5610df5a26
* chore: Reduce no-explicit-any warnings in server directory Tightens types across test response bodies, decorator signatures, the TestServer wrapper, base class generics, and presenter Record types. Where any is genuinely load-bearing (Sequelize model generics, PropertyDescriptor decorator returns, plugin-registered template classes, Fix mixin), keeps any with a targeted eslint-disable plus reason rather than masking the constraint. Cuts server-only no-explicit-any warnings from 162 to 70. * fix: groups test asserts on first response instead of second Caught by Copilot review on the no-explicit-any cleanup. Also fixes the pre-existing getChangsetSkipped → getChangesetSkipped typo surfaced while reviewing nearby decorator code.
28 lines
702 B
TypeScript
28 lines
702 B
TypeScript
import size from "lodash/size";
|
|
import { addAttributeOptions } from "sequelize-typescript";
|
|
|
|
/**
|
|
* A decorator that validates the size of a string based on lodash's size.
|
|
* function. Useful for strings with unicode characters of variable lengths.
|
|
*/
|
|
export default function Length({
|
|
msg,
|
|
min = 0,
|
|
max,
|
|
}: {
|
|
msg?: string;
|
|
min?: number;
|
|
max: number;
|
|
}): (target: object, propertyName: string) => void {
|
|
return (target: object, propertyName: string) =>
|
|
addAttributeOptions(target, propertyName, {
|
|
validate: {
|
|
validLength(value: string) {
|
|
if (size(value) > max || size(value) < min) {
|
|
throw new Error(msg);
|
|
}
|
|
},
|
|
},
|
|
});
|
|
}
|