32 lines
834 B
TypeScript
32 lines
834 B
TypeScript
import { StoryConfig } from "./config";
|
|
|
|
export interface ValidationResult {
|
|
is_public_domain: boolean;
|
|
message: string;
|
|
}
|
|
|
|
export function validatePublicDomain(storyConfig: StoryConfig): ValidationResult {
|
|
const publicationYear = storyConfig.metadata.publication_year;
|
|
if (!publicationYear) {
|
|
return {
|
|
is_public_domain: false,
|
|
message: "Publication year not found in metadata.",
|
|
};
|
|
}
|
|
|
|
const currentYear = new Date().getFullYear();
|
|
const cutoffYear = currentYear - 95;
|
|
|
|
if (publicationYear > cutoffYear) {
|
|
return {
|
|
is_public_domain: false,
|
|
message: `Work published in ${publicationYear} is not yet in the US public domain (cutoff: ≤ ${cutoffYear}).`,
|
|
};
|
|
}
|
|
|
|
return {
|
|
is_public_domain: true,
|
|
message: "Work is in the public domain in the US (95-year rule).",
|
|
};
|
|
}
|