UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

25 lines (24 loc) 1.09 kB
import type * as Joi from 'joi'; import { type FlowrMessage, type IdMessageBase, type MessageDefinition } from './messages/all-messages'; import type { Socket } from './net'; export interface ValidationErrorResult { type: 'error'; reason: Joi.ValidationError | Error; } export interface SuccessValidationResult<T extends IdMessageBase> { type: 'success'; message: T; } export type ValidationResult<T extends IdMessageBase> = SuccessValidationResult<T> | ValidationErrorResult; /** * Check that the serialized input is a valid base message. */ export declare function validateBaseMessageFormat(input: string): ValidationResult<IdMessageBase>; /** * Validates that the given input matches the given message definition. */ export declare function validateMessage<T extends FlowrMessage | IdMessageBase>(input: IdMessageBase, def: MessageDefinition<T>): ValidationResult<T>; /** * Sends an error message to the given client indicating a validation error. */ export declare function answerForValidationError(client: Socket, result: ValidationErrorResult, id?: string): void;