🎨 move field error to util
This commit is contained in:
		
							parent
							
								
									9cf018d737
								
							
						
					
					
						commit
						214d6b821c
					
				| @ -1,8 +1,6 @@ | ||||
| import { NextFunction, Request, Response } from "express"; | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import { EntityNotFoundError } from "typeorm"; | ||||
| import { FieldError } from "@fosscord/api"; | ||||
| import { ApiError } from "@fosscord/util"; | ||||
| import { ApiError, FieldError } from "@fosscord/util"; | ||||
| const EntityNotFoundErrorRegex = /"(\w+)"/; | ||||
| 
 | ||||
| export function ErrorHandler(error: Error, req: Request, res: Response, next: NextFunction) { | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import { Request } from "express"; | ||||
| import { ntob } from "./Base64"; | ||||
| import { FieldErrors } from "./FieldError"; | ||||
| import { FieldErrors } from "@fosscord/util"; | ||||
| 
 | ||||
| export function checkLength(str: string, min: number, max: number, key: string, req: Request) { | ||||
| 	if (str.length < min || str.length > max) { | ||||
|  | ||||
| @ -1,5 +1,4 @@ | ||||
| export * from "./Base64"; | ||||
| export * from "./FieldError"; | ||||
| export * from "./ipAddress"; | ||||
| export * from "./Message"; | ||||
| export * from "./passwordStrength"; | ||||
|  | ||||
| @ -3,6 +3,7 @@ import { | ||||
| 	EVENT, | ||||
| 	Event, | ||||
| 	EventData, | ||||
| 	FieldErrors, | ||||
| 	FosscordApiErrors, | ||||
| 	getPermission, | ||||
| 	PermissionResolvable, | ||||
| @ -15,7 +16,6 @@ import fs from "fs"; | ||||
| import path from "path"; | ||||
| import Ajv from "ajv"; | ||||
| import { AnyValidateFunction } from "ajv/dist/core"; | ||||
| import { FieldErrors } from ".."; | ||||
| import addFormats from "ajv-formats"; | ||||
| 
 | ||||
| const SchemaPath = path.join(__dirname, "..", "..", "assets", "schemas.json"); | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| export const EMAIL_REGEX = | ||||
| 	/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||||
| 
 | ||||
| export function adjustEmail(email: string): string | undefined { | ||||
| export function adjustEmail(email?: string): string | undefined { | ||||
| 	if (!email) return email; | ||||
| 	// body parser already checked if it is a valid email
 | ||||
| 	const parts = <RegExpMatchArray>email.match(EMAIL_REGEX); | ||||
|  | ||||
| @ -5,8 +5,9 @@ export * from "./cdn"; | ||||
| export * from "./Config"; | ||||
| export * from "./Constants"; | ||||
| export * from "./Database"; | ||||
| export * from "./Event"; | ||||
| export * from "./Email"; | ||||
| export * from "./Event"; | ||||
| export * from "./FieldError"; | ||||
| export * from "./Intents"; | ||||
| export * from "./MessageFlags"; | ||||
| export * from "./Permissions"; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy