Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么ValidationError的ErrorCode必须是Integer? #38

Open
kaixlin opened this issue Dec 2, 2018 · 5 comments
Open

为什么ValidationError的ErrorCode必须是Integer? #38

kaixlin opened this issue Dec 2, 2018 · 5 comments

Comments

@kaixlin
Copy link

kaixlin commented Dec 2, 2018

因为我们项目中使用的ErrorCode是用String数据类型,所以String数据类型感觉会更通用一些吧。

@neoremind
Copy link
Owner

嗯呢,ErrorCode用string或者int这个没有准则吧,只是这个类库选择了int,code一般都会有错误码,数字达意了。

@tiagocpeixoto
Copy link

tiagocpeixoto commented Dec 17, 2018

Just extends ValidationError like I did. Example:

public class FluentValidationError extends ValidationError {
	private String errorKey;

	public String getErrorKey() {
		return errorKey;
	}

	public FluentValidationError setErrorKey(String errorKey) {
		this.errorKey = errorKey;
		return this;
	}
}

@neoremind
Copy link
Owner

@tiagocpeixoto great catch!

@dongzl
Copy link

dongzl commented Dec 11, 2021

也遇到了相同的问题,现在项目定义的 ErrorCode 是 string类型

@neoremind
Copy link
Owner

项目初始考虑欠佳,可以通过上面 tiagocpeixoto 的扩展方式workaround支持下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants