1.0.6 • Published 5 months ago

@elmabs/elewise.elma365.ui.validation v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

EleWise.ELMA365.UI.Validation

npm i @elmabs/elewise.elma365.ui.validation

Содержание

Быстрый старт

import { ValidationManager, PropertyType } from '...';

// 1. Создаем менеджер валидации
const manager = new ValidationManager([
   {
      name: 'email',
      display: 'Email',
      type: PropertyType.String,
      rules: {
         required: true,
         pattern: '^\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,3}$',
      },
   },
   {
      name: 'age',
      display: 'Возраст',
      type: PropertyType.Number,
      rules: {
         required: true,
         min: 18,
         max: 99,
      },
   },
]);

// 2. Выполняем валидацию
const result = manager.validate({
   email: 'test@example.com',
   age: 25,
});

// 3. Обрабатываем результат
if (result.errors.length > 0) {
   console.error('Ошибки валидации:', result.errors);
} else {
   console.log('Данные валидны!');
}
1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago