@polargold/pg-frontend-vue
    Preparing search index...

    Function useJoiValidation

    • Joi schema validation with debounced re-validation and translated, per-field error messages - the Joi-flavored sibling to useValidationMethods (which wraps Vuelidate). Company convention (pg-api-guidelines-validation) names both: Vuelidate for single forms, Joi for assembled/aggregate data - only the Vuelidate half had made it into this package until now.

      Generalized from luv-autoq-frontend's useValidationStore - drops its app-specific ElementName field-name typing (now a plain string) and its direct useI18n() import (now the translate callback). Its renderJoiErrorMessages helper (filtering error details by field) is inlined here rather than kept as a separate export - it was only ever used from within this composable.

      Type Parameters

      • T

      Parameters

      Returns {
          debouncedValidate: DebouncedFunc<() => Promise<void>>;
          errorMessages: Ref<
              | {
                  context?: {
                      key?: string;
                      label?: string;
                      value?: any;
                      [key: string]: any;
                  };
                  message: string;
                  path: (string | number)[];
                  type: string;
              }[]
              | undefined,
              | ValidationErrorItem[]
              | {
                  context?: {
                      key?: string;
                      label?: string;
                      value?: any;
                      [key: string]: any;
                  };
                  message: string;
                  path: (string | number)[];
                  type: string;
              }[]
              | undefined,
          >;
          fieldHasError: (fieldName: string) => boolean;
          getErrorsForField: (fieldName: string) => ValidationErrorItem[];
          getTranslatedErrorMessage: (fieldName: string) => string[];
          hasErrors: ComputedRef<boolean>;
          reset: () => Promise<void>;
          validate: () => Promise<void>;
      }