Crate credify

Source
Expand description

LinkedIn profile URL validation library with AI-first design (v0.4.0).

Credify provides comprehensive LinkedIn URL validation with multiple API levels, from simple boolean checks to rich structured data optimized for AI agents and LLM tool calling, especially with frameworks like Rig.

§Features

  • 🤖 AI-First Design - Multiple API levels for different use cases
  • 🎯 Rig Framework Optimized - Ergonomic async helpers that prevent runtime panics
  • Async & Sync APIs - Full async support for modern applications
  • 📊 Structured Responses - Rich data with confidence scores and decisions
  • 🔍 Smart Validation - Format checking and existence verification
  • 🛡️ Never Panics - Comprehensive error handling throughout

§Quick Start

use credify::{rig_is_valid, rig_validate_text};

// Ultra-simple validation
if rig_is_valid("https://linkedin.com/in/johndoe").await {
    println!("Valid LinkedIn profile!");
}

// Get a human-readable response  
let message = rig_validate_text("https://linkedin.com/in/johndoe").await;
println!("{}", message); // "✅ Valid profile @johndoe (95% confidence)"

§Traditional API

use credify::{LinkedInValidator, LinkedInUrlError};

let validator = LinkedInValidator::new().expect("Failed to create validator");
match validator.is_valid_linkedin_profile_url("https://www.linkedin.com/in/johndoe") {
    Ok(_) => println!("Profile exists!"),
    Err(LinkedInUrlError::ProfileNotFound) => println!("Profile not found"),
    Err(LinkedInUrlError::AuthenticationRequired) => println!("LinkedIn requires auth"),
    Err(e) => println!("Error: {}", e),
}

§Format validation only

use credify::is_valid_linkedin_profile_format;

if is_valid_linkedin_profile_format("https://www.linkedin.com/in/johndoe") {
    println!("Valid LinkedIn profile URL format");
}

§LLM-friendly validation

use credify::validate_for_llm;

let result = validate_for_llm("https://www.linkedin.com/in/johndoe");
println!("{}", result);
// Parse the structured output for automated decision making

§AI-optimized API

use credify::{ai_validate, AIDecision};

let result = ai_validate("https://www.linkedin.com/in/johndoe");

// Simple boolean check
if result.is_valid {
    println!("Valid profile!");
}

// Use confidence level
if result.confidence >= 0.9 {
    println!("High confidence validation");
}

// AI decision making
match result.decision {
    AIDecision::Accept => println!("Use this profile"),
    AIDecision::Retry => println!("Try again later"),
    AIDecision::Reject => println!("Invalid URL"),
}

// Get JSON for direct consumption
use credify::ai_validate_json;
let json = ai_validate_json("https://linkedin.com/in/user");

§Rig Tool Implementation

async fn call(&self, args: Args) -> Result<String, Error> {
    // Just one line! No runtime panics, perfect for Rig
    Ok(credify::rig_validate_json(&args.url).await)
}

§API Levels

Credify provides multiple API levels for different use cases:

API LevelFunctionsUse Case
Ergonomic Rigrig_* functionsAI agents, Rig tools
AI-Optimizedai_* functionsStructured data for AI
LLM-Friendlyvalidate_for_llm*Verbose text reports
TraditionalLinkedInValidatorDirect validation

§Important: Async Usage

When using Credify in async contexts, always use async versions:

// ❌ WRONG - Can panic in async context
// let result = credify::ai_validate_json(url);

// ✅ CORRECT - Use async version
let result = credify::ai_validate_json_async("url").await;

// ✅ BEST - Rig helpers are always async
let result = credify::rig_validate_json("url").await;

Structs§

AIValidationResult
AI-agent friendly validation result with structured data
LinkedInValidator
A LinkedIn profile validator that performs HTTP requests to verify profile existence.
RigValidationResult
Ergonomic validation result optimized for Rig tool responses
ValidationMetadata
Validation metadata for advanced AI agents

Enums§

AIDecision
Simple decision enum for AI agents
LinkedInUrlError
Errors that can occur during LinkedIn URL validation.

Functions§

ai_validate
Validate LinkedIn URL optimized for AI agents (sync version)
ai_validate_async
Async version of ai_validate
ai_validate_json
Get validation result as JSON for AI agents
ai_validate_json_async
Async version of ai_validate_json
is_valid_linkedin_profile_format
Checks if a URL has valid LinkedIn profile format without making network calls.
rig_is_valid
Quick validation check for Rig - returns just true/false
rig_validate
Validate LinkedIn URL with Rig-optimized response format
rig_validate_json
Rig-optimized JSON validation with clean structure
rig_validate_text
Get validation as a one-line string for Rig tool responses
validate_for_llm
Validates a LinkedIn profile URL and returns a structured string for LLM consumption.
validate_for_llm_async
Validates a LinkedIn profile URL asynchronously and returns a structured string for LLM consumption.
validate_linkedin_url_async
Validates a LinkedIn profile URL asynchronously.