Ejemplo n.º 1
0
        public async Task <FlowResult> ValidateAsync(IStateManager stateManager,
                                                     MoveModel model)
        {
            FlowResult result = new FlowResult();

            if (model.InstanceId.GuidIsEmpty())
            {
                result.Errors.Add(new FlowError(FlowErrors.ServiceIsEmpty, args: nameof(model.Comment)));
            }

            if (model.TransitionId.GuidIsEmpty())
            {
                result.Errors.Add(new FlowError(FlowErrors.ServiceIsRequired, args: nameof(model.TransitionId)));
            }

            if (model.IdentityId.StringIsEmpty())
            {
                result.Errors.Add(new FlowError(FlowErrors.ServiceIsRequired, args: nameof(model.IdentityId)));
            }

            if (model.Comment.StringIsEmpty())
            {
                result.Warns.Add(new FlowWarn(FlowErrors.ServiceIsEmpty, args: nameof(model.Comment)));
            }

            if (model.Payload.StringIsEmpty())
            {
                result.Warns.Add(new FlowWarn(FlowErrors.ServiceIsEmpty, args: nameof(model.Payload)));
            }

            var validateSourceDestinationResult = await ValidateSourceDestinationAsync(stateManager, model);

            var validatePossibleMoveResult = await ValidatePossibleMoveAsync(stateManager, model);

            var validateInstanceResult = await ValidateInstanceAsync(stateManager, model);

            return(result.Merge(validateInstanceResult)
                   .Merge(validatePossibleMoveResult)
                   .Merge(validateSourceDestinationResult));
        }