The value to validate
Type predicate indicating if the value is a valid InChI string
isInChI("InChI=1S/H2O/h1H2") // Returns true
isInChI("1S/C2H2O4.2K/c3-1(4)2(5)6;;/h(H,3,4)(H,5,6);;/q;2*+1/p-2") // Returns true
isInChI("not an inchi") // Returns false
export function isInChI(value: unknown): value is InChI<string> {
return typeof value === 'string' && /^(InChI=)?1S?\/.+/.test(value);
}
Type guard to validate if a value is an InChI string. Accepts values with or without the leading
InChI=prefix (the version layer1S/...or1/...must follow).