The value to validate
Type predicate indicating if the value is a valid PubChem CID
isPubChemCID(11413) // Returns true
isPubChemCID("11413") // Returns true
isPubChemCID(0) // Returns false
isPubChemCID("abc") // Returns false
export function isPubChemCID(value: unknown): value is PubChemCID {
if (typeof value !== 'number' && typeof value !== 'string') return false;
const num = typeof value === 'string' ? Number(value) : value;
return Number.isInteger(num) && num > 0;
}
Type guard to validate if a value is a PubChem Compound ID (a positive integer). Numeric strings are accepted and coerced before validation.