func Validate(contentType string, fieldsDef map[string]definition.FieldDef, inputs InputMap, checkAllRequired bool) (bool, ValidationResult) {
	result := ValidationResult{Fields: map[string]string{}}
	for identifier, fieldDef := range fieldsDef {
		input, fieldExists := inputs[identifier]
		fieldResult := ""
		if fieldExists {
			isEmpty := fieldtype.IsEmptyInput(input)
			if fieldDef.Required && isEmpty {
				fieldResult = "1"
			} else {
				fieldtypeDef := fieldtype.GetFieldtype(fieldDef.FieldType)
				handler := fieldtypeDef.NewHandler(fieldDef)
				if handler != nil {
					_, err := handler.LoadInput(input, "")
					if _, ok := err.(fieldtype.ValidationError); ok {
						fieldResult = err.Error()
					}
					if _, ok := err.(fieldtype.EmptyError); ok {
						fieldResult = "1"
					}
				}
			}
		} else if fieldDef.Required && checkAllRequired {
			fieldResult = "1"
		}
		if fieldResult != "" {
			result.Fields[identifier] = fieldResult
		}
	}
	return result.Passed(), result
}
Validate validates and returns a validation result.
Validate is used in Create and Update, but can be also used separately
eg. when you have several steps, you want to validate one step only(only the fields in that step).
package handler
import (
	"context"
	"database/sql"
	"errors"
	"fmt"
	"strconv"
	"strings"
	"time"
	"github.com/digimakergo/digimaker/core/contenttype"
	"github.com/digimakergo/digimaker/core/db"
	"github.com/digimakergo/digimaker/core/definition"
	"github.com/digimakergo/digimaker/core/fieldtype"
	"github.com/digimakergo/digimaker/core/log"
	"github.com/digimakergo/digimaker/core/permission"
	"github.com/digimakergo/digimaker/core/query"
	"github.com/digimakergo/digimaker/core/util"
)
type InputMap map[string]interface{}
var ErrorNoPermission = errors.New("The user doesn't have access to the action.")