One option is to place your validation logic in a service layer.
一个选择就是把验证代码放到“Service”层中。
One thing we certainly need in the near term is some validation logic.
我们近期肯定需要的一件事就是某种验证逻辑。
The invocation handler class is where all of the data validation logic is handled.
调用处理程序类是处理所有数据验证逻辑的地方。
Here, the validation logic is run as part of a service external to the object that is calling it.
在这里,验证逻辑作为调用对象的外部服务运行。
Additionally, we've moved all our validation logic into one place, avoiding redundancy in the code.
另外,我们已将所有的验证逻辑移至一处,从而避免代码中出现冗余。
Because our example application included a business delegate class, we placed the validation logic there.
因为示例应用程序包含了一个业务委派类,所以我们在其中放置了验证逻辑。
The validation logic used by the MRM parser does not conform exactly to the W3C XML Schema specification.
MRM解析器使用的验证逻辑并不完全遵守W3CXML模式规范。
The constraints are defined in the bean (domain object) so the validation logic is close to the domain model.
约束是定义在一个bean(领域对象)中的,因此校验逻辑离领域模型最近。
Fortunately, tight coupling isn't the only option when it comes to coding the User interface's validation logic.
幸运的是,紧密耦合不是我们在编写User接口的验证逻辑时的唯一选项。
They serve to make the document easier to understand to the naked eye as opposed to providing any validation logic.
相比于给出任何验证逻辑而言,这样做只是为了使文档更易于理解。
In many cases, validation logic that you cannot implement in XML Schema or DTD is incorporated into application code.
在很多情况下,用XMLSchema或DTD不能实现的验证逻辑被并入到应用程序代码中。
Most business methods contain validation logic to ensure that pre-conditions are met before carrying out business logic.
大多数业务方法都包含验证逻辑,以确保在执行业务逻辑之前,前提条件得到满足。
The presentation layer can call the validation logic on the data provided by a form before passing it to the domain model.
展示层可以调用验证逻辑对表单提供的数据进行验证,然后再将该数据传递给域模型。
What follows is some validation logic to ensure that the user actually selected values prior to clicking the Search button.
接下来是一些验证逻辑,它们确保用户在单击Search按钮之前选择了某些值。
Listing 3 shows how a validation service can be used to decouple validation logic from the implementation's core business logic.
清单3显示了如何用验证服务把验证逻辑从核心业务逻辑实现中去耦。
Therefore, you must write the inline custom validation logic as if it were dealing with validation in a custom Validator object.
因此,必须编写嵌入自定义验证逻辑,就像使用一个自定义Validator对象处理验证一样。
The basic idea is that the BRMS decouples an application's business logic from its data validation logic and from its flow control.
其基本思想在于,BRMS将应用程序的业务逻辑与其数据验证逻辑和流程控制分离开来。
While this approach works to decouple the interface's validation logic from its core business code, it isn't very reusable or configurable.
虽然这种方法可以把接口的验证逻辑从它的核心业务代码去耦,但是它的可重用性和可配置性不是很强。
Note that the simple methods in Listing 1 can be called from other classes, such as our business delegates, to perform validation logic as needed.
可以从诸如业务委派等其它类上调用清单1中的简单方法,以按需执行验证逻辑。
The issue here is that existing applications effectively control enterprise data access through implementation of the data access and validation logic.
这儿的问题是现有应用通过实现数据存取和验证逻辑有效控制了企业数据的访问。
In this example, the validation logic is tightly coupled to the object in which it's being used. The weaknesses of this approach should be fairly obvious.
在这个示例里,验证逻辑和使用它的对象紧密耦合在一起。
Add to that the time, effort, and risk associated with recompiling and redeploying that code to a production server every time the validation logic changes.
除此之外,每次验证逻辑改变,还将承担将代码重新编译和部署到产品服务器的时间、精力和风险。
Validation processes are often scattered throughout method calls, making it difficult to tell the difference between validation logic and core business logic.
验证过程经常散落在方法调用里,这样就造成很难区分验证逻辑和核心业务逻辑。
So, application flow control logic belongs in a controller and data access logic belongs in a repository. In that case, where do you put your validation logic?
现在我们的应用程序流控制逻辑从控制器开始,数据库访问逻辑由repository负责,现在我们要把验证逻辑放在哪里呢?
You can also define the validation rules externally, in which case changing the validation logic will be a matter of changing the validation service's configuration.
您也可以在外部定义验证规则,在这种情况下,修改验证逻辑,就只是修改验证服务配置的问题了。
Using this technique, you could execute custom validation logic before allowing the form to be submitted, or you could trigger a custom event after the form is submitted.
使用这种技术,您可以在允许提交表单之前执行定制验证逻辑,或者在表单提交之后触发一个定制事件。
For the purpose of this example I'll use a validation-free implementation of the User interface, because the validation logic is being handled in the invocation handler.
出于本示例的需要,我会采用不受验证限制的方式实现User接口,因为验证逻辑是在调用处理程序中处理的。
The first step to improving our data-format validation procedure is to move all the validation logic into a single helper class, from which other methods can invoke it as needed.
改进数据格式验证过程的第一步是将所有的验证逻辑都移至一个助手类中,其它方法可以按需从这个类上调用验证逻辑。
Dynamic proxy classes give us a way to easily handle validation on any method in a uniform way, while completely separating all of the validation logic from the core business logic.
动态代理类给了我们一种以统一方式方便地处理任何方法上的验证途径,同时把所有的验证逻辑完全与核心业务逻辑分离开。
We prefer the latter option because it allows us to simply associate a custom converter (with built-in validation logic) with a specific object type and have JSF handle that object type.
我们偏向后一种方法,因为它让我们可以将自定义转换器(自带验证逻辑)与特定的对象类型相关联,并让JSF处理这种对象类型。
应用推荐