> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deasylabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate Test Cases

> Evaluate test cases against multiple regex patterns.

This route allows users to validate regex patterns using Python's regex engine,
which is important because Python regex and JavaScript regex have differences.
Tests each case against all patterns and returns whether it matched.

A test case is considered to match if ANY of the provided patterns match it.

Args:
    patterns: List of regex patterns to test (with description and optional output_value)
    test_cases: List of test cases with text, expected match behavior, and category

Returns:
    EvaluateTestCasesResponse with evaluated test cases showing actual_match results



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /evaluate_test_cases
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /evaluate_test_cases:
    post:
      tags:
        - Tags
      summary: Evaluate Test Cases
      description: >-
        Evaluate test cases against multiple regex patterns.


        This route allows users to validate regex patterns using Python's regex
        engine,

        which is important because Python regex and JavaScript regex have
        differences.

        Tests each case against all patterns and returns whether it matched.


        A test case is considered to match if ANY of the provided patterns match
        it.


        Args:
            patterns: List of regex patterns to test (with description and optional output_value)
            test_cases: List of test cases with text, expected match behavior, and category

        Returns:
            EvaluateTestCasesResponse with evaluated test cases showing actual_match results
      operationId: evaluate_test_cases_evaluate_test_cases_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvaluateTestCasesRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluateTestCasesResponse'
        '403':
          description: Missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '500':
          description: >-
            Internal Server Error. An unexpected error occurred while processing
            the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - BasicAuth: []
        - BearerAuth: []
          UserIdAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from unstructured import UnstructuredClient

            client = UnstructuredClient(
                username=os.environ.get("UNSTRUCTURED_USERNAME"),  # This is the default and can be omitted
                password=os.environ.get("UNSTRUCTURED_PASSWORD"),  # This is the default and can be omitted
            )
            response = client.tags.pattern.evaluate_test_cases(
                patterns=[{
                    "pattern": "pattern"
                }],
                test_cases=[{
                    "category": "category",
                    "should_match": True,
                    "text": "text",
                }],
            )
            print(response.evaluated_test_cases)
        - lang: JavaScript
          source: |-
            import UnstructuredClient from 'unstructured-sdk';

            const client = new UnstructuredClient({
              authMethod: 'My Auth Method',
              username: process.env['UNSTRUCTURED_USERNAME'], // This is the default and can be omitted
              password: process.env['UNSTRUCTURED_PASSWORD'], // This is the default and can be omitted
            });

            const response = await client.tags.pattern.evaluateTestCases({
              patterns: [{ pattern: 'pattern' }],
              test_cases: [
                {
                  category: 'category',
                  should_match: true,
                  text: 'text',
                },
              ],
            });

            console.log(response.evaluated_test_cases);
components:
  schemas:
    EvaluateTestCasesRequest:
      properties:
        patterns:
          items:
            $ref: '#/components/schemas/RegexPatternEvaluate'
          type: array
          title: Patterns
        test_cases:
          items:
            $ref: '#/components/schemas/TestCase'
          type: array
          title: Test Cases
      type: object
      required:
        - patterns
        - test_cases
      title: EvaluateTestCasesRequest
      description: Request to evaluate test cases against multiple regex patterns.
    EvaluateTestCasesResponse:
      properties:
        evaluated_test_cases:
          items:
            $ref: '#/components/schemas/EvaluatedTestCase'
          type: array
          title: Evaluated Test Cases
      type: object
      required:
        - evaluated_test_cases
      title: EvaluateTestCasesResponse
      description: Response from evaluating test cases.
    HTTPError:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: HTTPError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RegexPatternEvaluate:
      properties:
        pattern:
          type: string
          title: Pattern
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        output_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Value
      type: object
      required:
        - pattern
      title: RegexPatternEvaluate
      description: A regex pattern to evaluate.
    TestCase:
      properties:
        text:
          type: string
          title: Text
        should_match:
          type: boolean
          title: Should Match
        category:
          type: string
          title: Category
        actual_match:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Actual Match
        validated:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Validated
        expected_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Expected Value
      type: object
      required:
        - text
        - should_match
        - category
      title: TestCase
    EvaluatedTestCase:
      properties:
        text:
          type: string
          title: Text
        should_match:
          type: boolean
          title: Should Match
        actual_match:
          type: boolean
          title: Actual Match
        category:
          type: string
          title: Category
        matched_patterns:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Matched Patterns
      type: object
      required:
        - text
        - should_match
        - actual_match
        - category
      title: EvaluatedTestCase
      description: Result of evaluating a test case against patterns.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````