@fullwhere/shared-tools

v1.4.10

Published

A bundle of tools for the FullWhere platform

Readme

Tools

A bundle of tools for the FullWhere platform

Installation

npm install

Development

# Build the project
npm run build

# Format code
npm run format

# Lint code
npm run lint

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

Testing

This project uses Jest for testing with comprehensive coverage of the FormSubmissionValidator class.

Test Coverage

  • FormSubmissionValidator: 95.83% statement coverage, 87.75% branch coverage
  • Constants: 100% coverage
  • Types: 100% coverage
  • Exceptions: 92.85% coverage

Test Structure

  • src/form-submission-validator/__tests__/simple.test.ts - Basic validation tests without dependencies (27 tests, all passing)
  • src/form-submission-validator/__tests__/FormSubmissionValidator.test.ts - Comprehensive validation tests with dependencies
  • src/form-submission-validator/__tests__/integration.test.ts - Complex integration scenarios

Exception Coverage

The tests cover all validation exceptions:

  • NPSOutOfRangeException - NPS value out of range (0-10)
  • CSATOutOfRangeException - CSAT value out of range (1-5)
  • NumberValueException - Non-numeric values for numeric fields
  • DateValidationException - Invalid date strings
  • EmailValidationException - Invalid email addresses
  • PhoneNumberValidationException - Invalid phone numbers
  • FileNameCountException - No files submitted for file fields
  • FileNameValidationException - Non-existent files referenced
  • DuplicateFileNameException - Duplicate file names
  • DuplicateFieldsException - Duplicate field submissions
  • ExtraFieldsException - Fields not in form definition
  • MissingFieldsException - Required fields not submitted
  • FieldNotFoundException - Field not found in form
  • InterDependentFieldNotFoundException - Dependent field missing
  • AllDependentFieldException - AND dependencies not met
  • SomeDependentFieldException - OR dependencies not met
  • ValueValidationException - Invalid values for choice fields
  • ValueCountException - Wrong number of values

Available Tools

FormSubmissionValidator

A comprehensive form validation library that supports:

  • Multiple field types (NPS, CSAT, Date, Email, Phone, Files, Text, Dropdown, Checkbox, etc.)
  • Field dependencies with AND/OR logic
  • Comparison operators (equals, not equals, greater than, less than, etc.)
  • File validation with duplicate detection
  • Custom value support
  • Comprehensive error reporting

SiftSerializer

A serializer for Sift entity matching.

License

ISC