Vana SDK - v0.1.0
    Preparing search index...

    Implementation function for grant validation with flexible return types

    The grant file data to validate

    Validation configuration options

    Either a GrantFile or GrantValidationResult depending on throwOnError setting

    • Validates a grant file with comprehensive schema and business rule checking.

      This function provides flexible validation with TypeScript overloads:

      • When throwOnError is false (or { throwOnError: false }), returns a detailed validation result
      • When throwOnError is true (default), throws specific errors or returns the validated grant

      Parameters

      • data: unknown

        The grant file data to validate (unknown type for safety)

      • options: GrantValidationOptions & { throwOnError: false }

        Validation options including grantee, operation, files, etc.

      Returns GrantValidationResult

      Either a GrantFile (when throwing) or GrantValidationResult (when not throwing)

      When the grant file structure is invalid

      When the grant has expired

      When the grantee doesn't match the requesting address

      When the requested operation is not allowed

      // Throwing mode (default) - returns GrantFile or throws
      const grant = validateGrant(data, {
      grantee: '0x123...',
      operation: 'llm_inference',
      });

      // Non-throwing mode - returns validation result
      const result = validateGrant(data, {
      grantee: '0x123...',
      throwOnError: false
      });
      if (result.valid) {
      console.log('Grant is valid:', result.grant);
      } else {
      console.log('Validation errors:', result.errors);
      }
    • Validates a grant file with comprehensive schema and business rule checking.

      This function provides flexible validation with TypeScript overloads:

      • When throwOnError is false (or { throwOnError: false }), returns a detailed validation result
      • When throwOnError is true (default), throws specific errors or returns the validated grant

      Parameters

      • data: unknown

        The grant file data to validate (unknown type for safety)

      • Optionaloptions:
            | Omit<GrantValidationOptions, "throwOnError">
            | GrantValidationOptions & { throwOnError?: true }

        Validation options including grantee, operation, files, etc.

      Returns GrantFile

      Either a GrantFile (when throwing) or GrantValidationResult (when not throwing)

      When the grant file structure is invalid

      When the grant has expired

      When the grantee doesn't match the requesting address

      When the requested operation is not allowed

      // Throwing mode (default) - returns GrantFile or throws
      const grant = validateGrant(data, {
      grantee: '0x123...',
      operation: 'llm_inference',
      });

      // Non-throwing mode - returns validation result
      const result = validateGrant(data, {
      grantee: '0x123...',
      throwOnError: false
      });
      if (result.valid) {
      console.log('Grant is valid:', result.grant);
      } else {
      console.log('Validation errors:', result.errors);
      }