migrate to root dir
This commit is contained in:
31
lib/pipeline/validator.ts
Normal file
31
lib/pipeline/validator.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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).",
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user