= Business Rules

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
:page-partial:


As explained xref:overview.adoc#business-rules[in the overview], when a domain object is rendered in the UI or the end-user interacts with the domain object through the UI, the framework applies a series of precondition business rules to each object member.
These can be summarised as *"see it, use it, do it"*.

.See it, use it, do it
****

* is the object member visible?

* if so, is the object member enabled?

* if so, are the supplied values valid? (can the user "do" it)?
****

The framework provides a multitude of ways to implement these business rules.

The simplest mechanism is to just implement the business rules imperatively in the domain object, or in a xref:mixins.adoc[mixin] for the object.

A more sophisticated approach, useful for decoupling functionality, is using xref:userguide:fun:overview.adoc#domain-events[domain events].
The domain event is emitted multiple times, for the various types of precondition checks (and if not vetoed, they are also emitted on the execution of the action itself).


include::business-rules/visibility.adoc[leveloffset=+1]
include::business-rules/usability.adoc[leveloffset=+1]
include::business-rules/validity.adoc[leveloffset=+1]
