ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard to validate if a value is an InChI string. Accepts values with or without the leading InChI= prefix (the version layer 1S/... or 1/... must follow).

      Parameters

      • value: unknown

        The value to validate

      Returns value is InChI<string>

      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);
      }