예제 #1
0
func (this *CreateValidator) validateRequest(createRequest *CreateRequest) (isValid bool, errorMessages []string) {
	if createRequest.StartDate > createRequest.EndDate {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_START_BEFORE_END_DATE))
	}

	if createRequest.StartDate <= time.Now().Unix() {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_START_DATE_IN_PAST))
	}

	if createRequest.StartDate >= time.Now().AddDate(1, 0, 0).Unix() {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_START_DATE_TOO_FAR))
	}

	if len(createRequest.Description) <= 0 {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_DESCRIPTION_REQUIRED))
	}

	if len(createRequest.Title) <= 0 {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_TITLE_REQUIRED))
	}

	if len(createRequest.ImageId) <= 0 {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_IMAGE_REQUIRED))
	}

	if !valid.IsUUID(createRequest.ImageId) {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString(configuration.R_IMAGE_ID_NOT_UUID))
	}

	//TODO Check ERROR_IMAGE_NOT_FOUND (check if image exists)
	isValid = len(errorMessages) == 0
	return isValid, errorMessages
}
예제 #2
0
func (this *GetValidator) validateRequest(getRequest *GetRequest) (isValid bool, errorMessages []string) {
	if getRequest.HackathonId == "" {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString("ERROR_HACKATHONID_REQUIRED"))
	} else if !valid.IsUUID(getRequest.HackathonId) {
		errorMessages = append(errorMessages, this.ResourceProvider.GetString("ERROR_HACKATHONID_INVALID"))
	}

	isValid = len(errorMessages) == 0
	return isValid, errorMessages
}
예제 #3
0
func (i IsUUIDChecker) IsFormat(data string) bool {
	return govalidator.IsUUID(data)
}