refactor
This commit is contained in:
44
adapters/bootstrap/LeagueConstraints.ts
Normal file
44
adapters/bootstrap/LeagueConstraints.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
export const LEAGUE_DESCRIPTION_CONSTRAINTS = {
|
||||
minLength: 20,
|
||||
maxLength: 1000,
|
||||
recommendedMinLength: 50,
|
||||
} as const;
|
||||
|
||||
export const LEAGUE_NAME_CONSTRAINTS = {
|
||||
minLength: 3,
|
||||
maxLength: 64,
|
||||
pattern: /^[a-zA-Z0-9].*$/, // Must start with alphanumeric
|
||||
forbiddenPatterns: [
|
||||
/^\s/, // No leading whitespace
|
||||
/\s$/, // No trailing whitespace
|
||||
/\s{2,}/, // No multiple consecutive spaces
|
||||
],
|
||||
} as const;
|
||||
|
||||
export type LeagueVisibilityType = 'ranked' | 'unranked';
|
||||
|
||||
export interface LeagueVisibilityConstraints {
|
||||
readonly minDrivers: number;
|
||||
readonly isPubliclyVisible: boolean;
|
||||
readonly affectsRatings: boolean;
|
||||
readonly requiresApproval: boolean;
|
||||
}
|
||||
|
||||
export const VISIBILITY_CONSTRAINTS: Record<LeagueVisibilityType, LeagueVisibilityConstraints> = {
|
||||
ranked: {
|
||||
minDrivers: 10,
|
||||
isPubliclyVisible: true,
|
||||
affectsRatings: true,
|
||||
requiresApproval: false, // Anyone can join public leagues
|
||||
},
|
||||
unranked: {
|
||||
minDrivers: 2,
|
||||
isPubliclyVisible: false,
|
||||
affectsRatings: false,
|
||||
requiresApproval: true, // Private leagues require invite/approval
|
||||
},
|
||||
};
|
||||
|
||||
// Export constants for validation
|
||||
export const MIN_RANKED_LEAGUE_DRIVERS = VISIBILITY_CONSTRAINTS.ranked.minDrivers;
|
||||
export const MIN_UNRANKED_LEAGUE_DRIVERS = VISIBILITY_CONSTRAINTS.unranked.minDrivers;
|
||||
Reference in New Issue
Block a user