mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-11-27 06:01:08 +08:00
fixed invalidUrl in license
This commit is contained in:
parent
c2a76f819e
commit
bf0ff3c020
@ -612,6 +612,7 @@ const msgs: LocaleMessageObject = {
|
||||
maxLength: 'Maximum length is {0}',
|
||||
minLength: 'Minimum length is {0}',
|
||||
invalidFormat: '{0} is invalid',
|
||||
invalidUrl: 'Invalid URL format',
|
||||
},
|
||||
error: {
|
||||
userLocked: 'Your account is locked.',
|
||||
|
@ -248,7 +248,7 @@ const createUtil = ({ store, error, app: { i18n } }: Context) => {
|
||||
);
|
||||
},
|
||||
requireNonEmptyArray: (name: TranslateResult = 'Field') => (v: any[]) => v.length > 0 || i18n.t('validation.required', [name]),
|
||||
url: (v: string) => !v || new RegExp((store.state as RootState).validations.urlRegex).test(v) || i18n.t('general.error.invalidUrl'),
|
||||
url: (v: string) => !v || new RegExp((store.state as RootState).validations.urlRegex).test(v) || i18n.t('validation.invalidUrl'),
|
||||
regex: (name: TranslateResult = 'Field', regexp: string) => (v: string) => {
|
||||
return !v || new RegExp(regexp).test(v) || i18n.t('validation.invalidFormat', [name]);
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.papermc.hangar.controller.extras;
|
||||
|
||||
import io.papermc.hangar.config.hangar.HangarConfig;
|
||||
import io.papermc.hangar.exceptions.HangarApiException;
|
||||
import io.papermc.hangar.util.StaticContextAccessor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -18,7 +19,7 @@ public class ApiUtils {
|
||||
* @return actual limit
|
||||
*/
|
||||
public static long limitOrDefault(@Nullable Long limit) {
|
||||
if (limit != null && limit < 1) throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Limit should be greater than 0");
|
||||
if (limit != null && limit < 1) throw new HangarApiException(HttpStatus.BAD_REQUEST, "Limit should be greater than 0");
|
||||
return Math.min(limit == null ? hangarConfig.projects.getInitLoad() : limit, hangarConfig.projects.getInitLoad());
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
||||
public class ProjectLicense {
|
||||
|
||||
private final String name;
|
||||
@Validate(SpEL = "@validate.regex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String url;
|
||||
|
||||
@JdbiConstructor
|
||||
|
@ -11,13 +11,13 @@ import java.util.Collection;
|
||||
|
||||
public class ProjectSettings {
|
||||
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String homepage;
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String issues;
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String source;
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String support;
|
||||
@Valid
|
||||
private final ProjectLicense license;
|
||||
|
@ -33,7 +33,7 @@ public class PendingVersion {
|
||||
@NotBlank(message = "version.new.error.noDescription")
|
||||
private final String description;
|
||||
private final FileInfo fileInfo;
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "general.error.invalidUrl")
|
||||
@Validate(SpEL = "@validate.optionalRegex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
|
||||
private final String externalUrl;
|
||||
@NotBlank(message = "version.new.error.channel.noName")
|
||||
@Validate(SpEL = "@validate.regex(#root, @hangarConfig.channels.nameRegex)", message = "channel.modal.error.invalidName")
|
||||
|
Loading…
Reference in New Issue
Block a user