Authentication Validators
Location:apps/web/app/auth/validators.ts
All authentication validators use VineJS for schema definition and validation.
signUpValidator
Validates user registration data.User’s full nameValidation:
- Trimmed whitespace
- Minimum length: 3 characters
- Maximum length: 255 characters
User’s email addressValidation:
- Valid email format
- Converted to lowercase
- Trimmed whitespace
- Must be unique in
userstable
User’s passwordValidation:
- Minimum length: 1 character
- Requires confirmation field
Password confirmation (must match password)
signInValidator
Validates user login credentials.User’s email addressValidation:
- Valid email format
- Converted to lowercase
- Trimmed whitespace
User’s passwordValidation:
- Minimum length: 1 character
forgotPasswordValidator
Validates forgot password request.Email address to send reset linkValidation:
- Valid email format
- Trimmed whitespace
- Normalized email format
- Gmail dots are preserved
resetPasswordValidator
Validates new password during reset.New passwordValidation:
- Minimum length: 1 character
- Requires confirmation
Password confirmation (must match password)
User Management Validators
Location:apps/web/app/users/validators.ts
createUserValidator
Validates data for creating a new user (admin function).User’s full name (3-255 characters, trimmed)
Unique email address (lowercase, trimmed)
Role ID (must exist in
roles table)Optional password (auto-generated if not provided)Validation:
- 1-255 characters
- Requires confirmation if provided
editUserValidator
Validates data for updating an existing user.This validator uses metadata to pass the current user ID for email uniqueness validation.Usage:
User’s full name (3-255 characters)
Email address (must be unique except for current user)
Role ID (must exist in database)
Optional new password (keeps existing if not provided)
updateProfileValidator
Validates profile updates for authenticated users.User’s full name (3-255 characters)
Profile picture uploadValidation:
- Allowed formats: PNG, JPG, JPEG, GIF
- Maximum size: ~1MB (1,038,336 bytes)
- Nullable (can be empty)
updatePasswordValidator
Validates password change requests.New password (1-255 characters, requires confirmation)
listUserValidator
Validates user listing/search parameters.Page number (positive integer, no decimals)
Results per page (positive integer, no decimals)
Search query (1-255 characters)
Array of role IDs to filter by (each must exist in
roles table)createTokenValidator
Validates API token creation.Optional token name (3-255 characters, defaults to “Secret Token”)
inviteUserValidator
Validates user invitation data.Invitee’s email address (must be unique)
Optional invitation message
Role to assign to the invited user
Common Validators
baseSearchValidator
Base schema for search and pagination parameters. Location:apps/web/app/common/validators/search.ts
Current page numberValidation:
- Must be a positive integer
- No decimal values
- Optional (defaults to 1)
Number of results per pageValidation:
- Must be a positive integer
- No decimal values
- Optional (defaults to 10)
Search query stringValidation:
- Minimum length: 1 character
- Maximum length: 255 characters
- Optional
Validation Usage
- Basic Usage
- With Metadata
- Error Handling
- Custom Rules
Validation Rules Reference
String Rules
String Rules
trim()- Remove leading/trailing whitespacetoLowerCase()/toUpperCase()- Convert caseminLength(n)- Minimum character countmaxLength(n)- Maximum character countemail()- Valid email formatnormalizeEmail()- Normalize email addressesconfirmed({ confirmationField })- Match another field
Number Rules
Number Rules
withoutDecimals()- Integer onlypositive()- Greater than zeromin(n)/max(n)- Range validationexists({ table, column })- Must exist in database
File Rules
File Rules
extnames([])- Allowed file extensionssize- Maximum file size in bytes- Example:
1 * 1024 * 1024= 1MB
Database Rules
Database Rules
unique({ table, column })- Must be unique in tableexists({ table, column })- Must exist in table- Custom async validation with database queries
Modifiers
Modifiers
optional()- Field is not requirednullable()- Accepts null valueswithMetaData<T>()- Add metadata for validation context