Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 22x 22x 83x 83x 24x 24x 121x 26x 26x 117x 22x 684x 41x 134x 108x 192x 474x 474x 153x 153x | // Keep in sync with source of truth from backend in app/backend/src/couchers/constants.py
const nameCharactersValidationPattern = /^[\p{L}\p{M}\p{Zs}\p{Pi}\p{Pf}\p{Pd},.'"·・&/|]+$/u;
const nameNoSurroundingWhitespaceValidationPattern = /^\P{Zs}(?:[\s\S]*\P{Zs})?$/u;
export const nameMinLength = 2;
export const nameMaxLength = 100;
export function validateNameChars(name: string) {
return nameCharactersValidationPattern.test(name) && nameNoSurroundingWhitespaceValidationPattern.test(name);
}
// Keep in sync with source of truth from backend in app/backend/src/couchers/constants.py
export const usernameValidationPattern = /^[a-z][0-9a-z_]*[a-z0-9]$/i;
export const validatePassword = (password: string) => {
return password.length >= 8 && password.length < 256;
};
// Keep in sync with source of truth from backend in app/backend/src/couchers/constants.py
export const emailValidationPattern =
/^[0-9a-z]([0-9a-z\-_+]|(\.[0-9a-z\-_+]))*@([0-9a-z-]+\.)*[0-9a-z-]+\.[a-z]{2,}$/i;
export const timePattern = /\d{2}:\d{2}/;
export const profileAboutMeMinLength = 150;
// Keep in sync with source of truth from backend in app/backend/src/couchers/constants.py
export const hostRequestMinLength = 250;
export const publicTripDescriptionMinLength = 150;
export const publicTripOfferMinLength = 100;
// The backend strips surrounding whitespace before checking a minimum length, so only count what it will keep.
export function charsRemaining(text: string, minLength: number) {
return Math.max(0, minLength - text.trim().length);
}
export function validatePastDate(stringDate: string) {
const date = new Date(stringDate);
return !isNaN(date.getTime()) && date < new Date();
}
export function lowercaseAndTrimField(name: string) {
return name.trim().toLowerCase();
}
|