/*
 * Copyright 2014-2015 the original author or authors.
 *
 * Licensed 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.
 */
package org.lastaflute.web.validation;

import org.lastaflute.web.ruts.message.ActionMessages;

/**
 * @param <MESSAGES> The type of action messages.
 * @author jflute
 */
public interface LaValidatable<MESSAGES extends ActionMessages> {

    default void validate(Object form, VaMore<MESSAGES> doValidateLambda, VaErrorHook validationErrorLambda) {
        createValidator().validate(form, doValidateLambda, validationErrorLambda);
    }

    default void validateApi(Object form, VaMore<MESSAGES> doValidateLambda) {
        createValidator().validateApi(form, doValidateLambda);
    }

    default void letsValidationError(VaMessenger<MESSAGES> messagesLambda, VaErrorHook validationErrorLambda) {
        createValidator().letsValidationError(() -> createMessages(), validationErrorLambda);
    }

    default void letsValidationErrorApi(VaMessenger<MESSAGES> messagesLambda) {
        createValidator().letsValidationErrorApi(() -> createMessages());
    }

    ActionValidator<MESSAGES> createValidator();

    MESSAGES createMessages();
}

@@ -904,34 +904,38 @@
 e%3CMESSAGES%3E 
-do
+more
 Validat
-e
+ion
 Lambda, VaEr
@@ -1004,34 +1004,38 @@
 idate(form, 
-do
+more
 Validat
-e
+ion
 Lambda, vali
@@ -1120,26 +1120,30 @@
 SSAGES%3E 
-do
+more
 Validat
-e
+ion
 Lambda) 
@@ -1192,18 +1192,22 @@
 rm, 
-do
+more
 Validat
-e
+ion
 Lamb
@@ -1269,33 +1269,43 @@
 enger%3CMESSAGES%3E 
-m
+validationM
 essagesLambda, V
@@ -1392,32 +1392,168 @@
 r(() -%3E 
-createMessages()
+%7B%0A            final MESSAGES messages = createMessages();%0A            validationMessagesLambda.message(messages);%0A            return messages;%0A        %7D
 , valida

change argument name for validation with editor templates