Skip to content

Walidacja

Validation is created using integration with two solutions:

  • vee-validate - the most popular library in the Vue ecosystem for forms
  • zod - TypeScript library for validation;

The above libraries are integrated with each other - https://vee-validate.logaretm.com/v4/integrations/zod-schema-validation/.

Usage rules

  • use CompositionAPI and composables useField and useForm;
  • useForm should provide information about meta, i.e. general information about the form and its validation status;
  • useField provides validation information for each field and provides model information to the component layer.

Universal

The use of zod results from the need to minimize the number of libraries used in Riupress. This library can be treated as universal for both Vue and Express/Node.js applications. When creating an API, the validation created there should reflect what the frontend application validates, or vice versa - when creating validations on the Vue application side, the development team should be able to do ctr+c/ctr+v validation for the backend application.

The acceptable difference between the above is the use of one object when validating data from a request for a backend application, whereas in a Vue application it will almost always be per-field validation.