A utility library for detecting forbidden content patterns in text. Used to validate prompts and descriptions before AI image generation to ensure compliance with content policies.
npm install @torqlab/check-forbidden-contentOr with Bun:
bun add @torqlab/check-forbidden-contentimport checkForbiddenContent from '@torqlab/check-forbidden-content';
const hasForbidenContent = checkForbiddenContent('A photo of a person running');
console.log(hasForbidenContent); // true
const isSafe = checkForbiddenContent('An athlete running through a scenic landscape');
console.log(isSafe); // falseThis library detects the following categories of forbidden content:
- Keywords:
person,people,individual,human,man,woman,child,kid,baby,face,portrait,photo,picture,image
- Keywords:
political,politics,government,president,election,vote,democracy,republican,democrat,flag,banner,symbol,emblem,crest
- Keywords:
violence,violent,fight,war,battle,weapon,gun,knife,sword,attack,kill,death,blood,combat,military,soldier,army,navy
- Keywords:
sexual,sex,nude,naked,explicit,adult,porn
- Keywords:
text,word,letter,alphabet,caption,typography,font
Checks if the provided text contains any forbidden content patterns.
Parameters:
text(string): The text to check for forbidden content.
Returns:
- (boolean):
trueif forbidden content is detected,falseotherwise.
MIT