@getcommunity/gc-validators
v0.0.169
Published
Schema Validator for GetCommunity web-stack types
Readme
name: "Get Community Validators" description: "A validation library for Get Community defining and validating data structures used throughout the application." category: "Web Development" repository: "https://github.com/getcommunity/gc-validators" author: "Joey Grable" authorUrl: "https://github.com/joeygrable94" tags: [ "Get Community", "homebuilder digital marketing", "website development", "validation library", "TypeScript", "NodeJS", "ValiBot" ] lastUpdated: "2025-10"
🪨 GC Validators
Project Overview
The Get Community Validators package provides a set of validation rules and utilities for ensuring data integrity and consistency across the Get Community application. It defines and validates data structures used throughout the application, ensuring that all data conforms to expected formats and business rules.
Tech Stack
Main technologies and tools used:
- TypeScript
- NodeJS
- ValiBot
- Pnpm
- NPM
Project Structure
gc-validators/
├── scripts/
├── src/
│ ├── constants/
│ ├── schemas/
│ ├── types/
│ │ ├── components/
│ │ │ ├── blocks/
│ │ │ ├── brand/
│ │ │ ├── forms/
│ │ │ ├── shared/
│ │ │ ├── slideshow/
│ │ │ ├── utm/
│ │ │ └── index.ts
│ │ ├── core/
│ │ ├── documents/
│ │ ├── singles/
│ │ └── index.ts
│ ├── utilities/
│ ├── validators/
│ └── index.ts
├── .vscode/
├── .env
├── .gitignore
├── .npmignore
├── .npmrc
├── .pre-commit-config.yaml
├── .prettierignore
├── .prettierrc.mjs
├── tsconfig.json
├── tsup.config.ts
├── pnpm-lock.yaml
└── package.jsonDevelopment Guidelines
Code Style
- Use consistent code formatting tools
- Use Prettier for code formatting
- Use ESLint for linting
- Use pre-commit hooks for code quality checks
- Follow language-specific best practices
- Keep code clean and readable
Naming Conventions
- File naming: (snake-case)
- all lowercase with hyphens
- append file type as suffix
- e.g.,
entity-schema.tsx,pagination-constants.ts
- Variable naming: (PascalCase, or UPPER_SNAKE_CASE)
- types should be in PascalCase (e.g.,
ClientDocument,BlogPostDocument) - global constants should be in UPPER_SNAKE_CASE (e.g.,
LIMIT_SHORT_STRING_MAX_LENGTH)
- types should be in PascalCase (e.g.,
- Function naming: (camelCase)
- use camelCase for function names (e.g.,
datePlusDays,hasPermission)
- use camelCase for function names (e.g.,
- Class and Schema naming: (PascalCase)
- use PascalCase for classes and schemas (e.g.,
PermissionCheck,RolesWithPermissions) - prefix entity action schemas with "S" and the CRUD operation (e.g.,
SUpdateClientDocument,SCreateContentPillarDocument)
- use PascalCase for classes and schemas (e.g.,
Git Workflow
Branching Strategy
productionbranch is used for production releasesmainbranch is used for staged productiondevbranch is used for developmenttestbranch is used for testingupgradebranch is used for upgrading dependenciesfeat-*branches are used for new featuresbugfix-*branches are used for bug fixes
Commit message format
- Get Community follows the Conventional Commit specification for commit messages.
Pull Request process
- All pull requests should be reviewed by at least one other team member and approved by by a code manager before merging.
- Ensure that all tests pass before merging.
- Use descriptive titles and provide context in the PR description.
Environment Setup
Each submodule contains an .env.example file that outlines the necessary environment variables. Copy this file to .env and fill in the appropriate values. Many of the env variable are managed in a secure vault and can be retrieved from the project manager.
Development Requirements
- Node.js version: >=22.x (LTS)
- Package manager: pnpm
- Other dependencies: Git
Installation Steps
# 1. Clone the library
git clone [repository-url]
# 2. Install dependencies
pnpm install
# 3. Build the library
pnpm buildCore Feature Implementation (TO DO)
Feature Module 1
Describe the implementation approach and key code examples for main features.
// Example code
function exampleFunction() {
// Implementation logic
}Testing Strategy
Unit Testing
- Testing framework:
- Test coverage requirements:
- Test file organization:
Integration Testing
- Test scenarios:
- Testing tools:
End-to-End Testing
- Test workflow:
- Automation tools:
Deployment Guide
Build Process
# Build command
pnpm buildDeployment Steps
- Prepare production environment
- Configure environment variables
- Execute deployment scripts
- Verify deployment results
Environment Variables
# Example environment variablesPerformance Optimization
Frontend Optimization
- Code splitting
- Lazy loading
- Caching strategies
Backend Optimization
- Database query optimization
- Caching mechanisms
- Load balancing
Security Considerations
Data Security
- Input validation
- SQL injection protection
- XSS protection
Authentication & Authorization
- User authentication flow
- Permission control
- Token management
Monitoring and Logging
Application Monitoring
- Performance metrics
- Error tracking
- User behavior analytics
Log Management
- Log levels
- Log format
- Log storage
Reference Resources
- [Official Documentation Link]
- [Related Tutorials]
- [Community Resources]
- [Best Practices Guide]
Examples
Permission Constants Usage
const userDoc: UserDocument = {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
username: "tester",
email: "[email protected]",
provider: "local",
confirmed: true,
blocked: true,
clerk_user_id: ""
}
const user: AuthorizedUserDocument = {
...userDoc,
role: {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
type: "employee",
name: "Employee",
description: "Employee role with access to client data",
permissions: []
},
account: {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
preferred_name: "Test Account",
first_name: "Test",
last_name: "User"
}
}
const client: ClientDocument = {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
title: "Test Client",
teamwork_name: "Test Client",
teamwork_id: "123456",
is_featured: true,
utm_sheet_id: "asdkjhflawhfl",
allow_create_utm_link: true,
is_organic_social: true,
is_paid_media: true,
is_active: true,
classification: ["organic", "paid"]
}
const clientUserStatus: ClientUserDocumentStatus = {
verified: true,
clientUser: {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
client: client,
user: userDoc,
scopes: ["client:access", "client:manager", "client-project:udate"]
},
scopes: ["client:access", "client:manager", "client-project:udate"]
}
const clientProject: ClientProjectDocument = {
id: 1,
documentId: "1234asdfhjkl",
createdAt: "2024-01-01T00:00:00.000Z",
updatedAt: "2024-01-01T00:00:00.000Z",
publishedAt: "2024-01-01T00:00:00.000Z",
title: "Test Client Project",
slug: "test-client-project",
project_status: ["for-sale"]
project_phase: "p1"
featured_image: null
}
// Check if user has permission to create a client project
hasPermission(user, clientUserStatus, "client-project", "create")
// > false
// Check if user has permission to update a client project
hasPermission(user, clientUserStatus, "client-project", "update", clientProject)
// > true
// Check if user has permission to access a client
hasPermission(user, clientUserStatus, "client", "access", client)
// > true