rename var

This commit is contained in:
Yanislav Igonin 2022-04-12 11:41:31 +03:00
parent 122637f5f3
commit ce98428cbe

View File

@ -102,44 +102,44 @@ func ValidatePost(title, text string, files []*multipart.FileHeader) string {
} }
func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Inputs { func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Inputs {
validationError := new(repositories.Inputs) validationErrors := new(repositories.Inputs)
hasErrors := false hasErrors := false
if text == "" && len(files) == 0 { if text == "" && len(files) == 0 {
validationError.Text = repositories.InvalidTextOrFilesErrorMessage validationErrors.Text = repositories.InvalidTextOrFilesErrorMessage
validationError.Files = repositories.InvalidTextOrFilesErrorMessage validationErrors.Files = repositories.InvalidTextOrFilesErrorMessage
hasErrors = true hasErrors = true
} }
if len([]rune(title)) > 100 { if len([]rune(title)) > 100 {
validationError.Title = repositories.InvalidTitleLengthErrorMessage validationErrors.Title = repositories.InvalidTitleLengthErrorMessage
hasErrors = true hasErrors = true
} }
if len([]rune(text)) > 1000 { if len([]rune(text)) > 1000 {
validationError.Text = repositories.InvalidTextLengthErrorMessage validationErrors.Text = repositories.InvalidTextLengthErrorMessage
hasErrors = true hasErrors = true
} }
if len(files) > 4 { if len(files) > 4 {
validationError.Files = repositories.InvalidFilesLengthErrorMessage validationErrors.Files = repositories.InvalidFilesLengthErrorMessage
hasErrors = true hasErrors = true
} }
isFilesExtsValid := CheckFilesExt(files) isFilesExtsValid := CheckFilesExt(files)
if !isFilesExtsValid { if !isFilesExtsValid {
validationError.Files = repositories.InvalidFileExtErrorMessage validationErrors.Files = repositories.InvalidFileExtErrorMessage
hasErrors = true hasErrors = true
} }
isFilesSizesNotToBig := CheckFilesSize(files) isFilesSizesNotToBig := CheckFilesSize(files)
if !isFilesSizesNotToBig { if !isFilesSizesNotToBig {
validationError.Files = repositories.InvalidFileSizeErrorMessage validationErrors.Files = repositories.InvalidFileSizeErrorMessage
hasErrors = true hasErrors = true
} }
if hasErrors { if hasErrors {
return validationError return validationErrors
} }
return nil return nil