Member Junction
    Preparing search index...

    Context object passed to semantic validators

    Contains all information needed to validate a prop value against semantic constraints.

    interface ValidationContext {
        ComponentName: string;
        ComponentSpec: ComponentSpec;
        Dialect?: SQLParserDialect;
        Entities: Map<string, EntityMetadata>;
        Node: Node;
        Path: NodePath<any>;
        propertyName: string;
        PropertyPresent?: boolean;
        propertyValue: ExtractedValue;
        Queries: Map<string, QueryMetadata>;
        siblingProps: Map<string, ExtractedValue>;
        TypeEngine: TypeInferenceEngine;
        findSimilarFieldNames(
            fieldName: string,
            entityName: string,
            maxResults?: number,
        ): string[];
        getEntityFields(entityName: string): EntityFieldInfo[];
        getEntityFieldType(entityName: string, fieldName: string): string | null;
        getQueryParameters(queryName: string): QueryParameter[];
        hasEntity(entityName: string): boolean;
        hasQuery(queryName: string, categoryPath?: string): boolean;
    }
    Index

    Properties

    ComponentName: string

    Name of the component being validated

    Example: "DataGrid", "EntityDataGrid", "SimpleChart"

    ComponentSpec: ComponentSpec

    Full component specification

    Provides access to:

    • Type definitions (for custom type validation)
    • Data requirements (entities, queries)
    • Other properties (for cross-property validation)
    • Dependency specs (for validating nested components)

    SQL dialect for WHERE clause parsing and validation.

    Used by the SqlWhereClauseValidator to parse SQL with the correct syntax for the target database platform (SQL Server, PostgreSQL, etc.). If not provided, the validator falls back to SQL Server dialect.

    Entities: Map<string, EntityMetadata>

    Map of entity name to entity metadata

    Populated from componentSpec.dataRequirements.entities Used by validators that check field names, entity references, etc.

    Example:

    const memberEntity = entities.get('Members');
    const fields = memberEntity.fields; // Array of EntityFieldInfo
    Node: Node

    The AST node being validated

    This is typically the JSXAttribute node, but validators can traverse to child nodes for more specific location information.

    Path: NodePath<any>

    Babel traversal path for the node

    Provides access to parent nodes, scope information, and AST manipulation. Validators should not modify the AST - this is read-only validation.

    propertyName: string

    Name of the property being validated

    Example: "fields", "columns", "entityName", "extraFilter"

    PropertyPresent?: boolean

    Whether the parent passed the property on the element.

    The linter sets this on every context it builds. It is false only for a validator that opted in with SemanticValidator.EvaluatesAbsentProp; then propertyValue is undefined and Node is the element's opening tag. Optional so contexts built outside the linter (tests, other tools) stay valid.

    propertyValue: ExtractedValue

    Extracted value of the property

    This is the result of PropValueExtractor.extract() and can be:

    • Primitive: string, number, boolean, null
    • Array: Array of extracted values
    • Object: Record<string, ExtractedValue>
    • DynamicValue: { _type: 'identifier' | 'expression', name?, description? }

    If the value is a DynamicValue, validators should typically skip validation and return an empty violations array (the linter will warn the user).

    Queries: Map<string, QueryMetadata>

    Map of query name to query metadata

    Populated from componentSpec.dataRequirements.queries Used by validators that check query references and parameters.

    Example:

    const query = queries.get('Sales by Region');
    const params = query.parameters; // Array of QueryParameter
    siblingProps: Map<string, ExtractedValue>

    Map of sibling props on the same JSX element

    Key is prop name, value is extracted value. Used for constraints with dependsOn to access related prop values.

    Example:

    // <EntityDataGrid entityName="Members" fields={['FirstName', 'LastName']} />
    siblingProps.get('entityName') // => "Members"
    siblingProps.get('fields') // => ['FirstName', 'LastName']
    TypeEngine: TypeInferenceEngine

    Type inference engine for checking expression types

    Used for advanced type checking beyond what PropValueExtractor provides. Can infer types of variables, function calls, etc.

    Methods

    • Find field names similar to the given field name (for suggestions)

      Uses fuzzy matching (Levenshtein distance or similar) to find close matches. Useful for "Did you mean?" error messages.

      Parameters

      • fieldName: string

        The field name to find matches for

      • entityName: string

        Name of the entity to search in

      • OptionalmaxResults: number

        Maximum number of suggestions (default: 3)

      Returns string[]

      Array of similar field names, sorted by similarity

      const suggestions = context.findSimilarFieldNames('FristName', 'Members', 3);
      // => ['FirstName', 'FirstNameNormalized', 'FirstNameMasked']
    • Get the data type of a specific field on an entity

      Parameters

      • entityName: string

        Name of the entity

      • fieldName: string

        Name of the field

      Returns string | null

      Data type string (e.g., 'string', 'number', 'date'), or null if not found

      const fieldType = context.getEntityFieldType('Members', 'JoinDate');
      // => 'date'
    • Check if a query exists in the component's data requirements

      Parameters

      • queryName: string

        Name of the query to check

      • OptionalcategoryPath: string

        Optional category path for disambiguation

      Returns boolean

      True if the query exists

      if (!context.hasQuery('Sales Report', '/Reports/Sales')) {
      // Query not found
      }