后缀 .RequiredError、.FormatError 等的用途是什么
阅读 Oxite 源代码,我发现验证器会保存带有一些后缀的错误属性名称(RequiredError、MaxLengthExceededError、InvalidError、FormatError),
validationState.Errors.Add(CreateValidationError(user.Name, "Name.RequiredError", "Name is not set"));
validationState.Errors.Add(CreateValidationError(user.Name, "Name.MaxLengthExceededError", "Username must be less than or equal to {0} characters long.", 256));
validationState.Errors.Add(CreateValidationError(user.Email, "Email.InvalidError", "Email is invalid."));
这些后缀的目的是什么? 他们怎么用的?
Reading the Oxite source code, I have found that validators save bad property name with some suffixes (RequiredError, MaxLengthExceededError, InvalidError, FormatError)
validationState.Errors.Add(CreateValidationError(user.Name, "Name.RequiredError", "Name is not set"));
validationState.Errors.Add(CreateValidationError(user.Name, "Name.MaxLengthExceededError", "Username must be less than or equal to {0} characters long.", 256));
validationState.Errors.Add(CreateValidationError(user.Email, "Email.InvalidError", "Email is invalid."));
What is the purpose of whose suffixes? How they used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,它们是恒定的、机器友好的值,可用于唯一地标识错误,并可用于为全球化站点获取本地化资源。
我很擅长猜测:不过我很
好奇。 因为异常通常不应该被本地化。
My guess is that they're constant, machine-friendly values that can be used to uniquely identify the error and can be used to fetch localized resources for your globalized site.
I'm a good guesser:
Curious, though. Since exceptions generally shouldn't be localized.