@getcommunity/gc-validators
v0.0.270
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.
Examples
Check if a user can be assigned a specific resource permission
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"
}
}
// Check if user can be assigned permission to create client projects
canAssignPermission(user, "client-project", "create")
// trueCheck if a user has permission to access a client assigned entity
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