Documentation ¶
Index ¶
- Constants
- func IsEnumValid(val reflect.Value, args ...string) bool
- func IsRangeValid(val reflect.Value, args ...string) bool
- func IsRegularValid(val reflect.Value, args ...string) bool
- func IsRequiredValid(val reflect.Value, args ...string) bool
- func PrepareActualValidationRules(customValidationRules map[string]ValidationCallback)
- type ErrorData
- type IError
- func HttpValidationError(args ...string) IError
- func New(code interface{}, message string) IError
- func NewF(code interface{}, message string, args ...interface{}) IError
- func NewFWithName(code interface{}, name string, message string, args ...interface{}) IError
- func NewWithName(code interface{}, name string, message string) IError
- func ValidateStruct(v interface{}) IError
- type PortError
- func (e *PortError) Code(code interface{}) IError
- func (e *PortError) Error() string
- func (e *PortError) FlushDetails() IError
- func (e *PortError) GetCode() interface{}
- func (e *PortError) GetDetails() []IError
- func (e *PortError) GetHTTP() int
- func (e *PortError) HTTP(httpCode int) IError
- func (e *PortError) IfDetails() IError
- func (e *PortError) MarshalJSON() ([]byte, error)
- func (e *PortError) MergeDetails(error ...IError) IError
- func (e *PortError) Origin() *PortError
- func (e *PortError) PopDetail() IError
- func (e *PortError) PushDetail(code interface{}, name string, message string) IError
- func (e *PortError) UnmarshalJSON(data []byte) error
- type ValidationCallback
- type ValidationRule
Constants ¶
const ( PortErrorSystem = "PORTABLE_ERROR_SYSTEM" PortErrorClient = "PORTABLE_ERROR_CLIENT" PortErrorDatabaseQuery = "PORTABLE_ERROR_DATABASE" PortErrorConsole = "PORTABLE_ERROR_CONSOLE" PortErrorLogic = "PORTABLE_ERROR_LOGIC" PortErrorRequest = "PORTABLE_ERROR_REQUEST" PortErrorResponse = "PORTABLE_ERROR_RESPONSE" PortErrorConflict = "PORTABLE_ERROR_CONFLICT" PortErrorTransaction = "PORTABLE_ERROR_TRANSACTION" PortErrorConnection = "PORTABLE_ERROR_CONNECTION" PortErrorUpdate = "PORTABLE_ERROR_UPDATE" PortErrorCreate = "PORTABLE_ERROR_CREATE" PortErrorDelete = "PORTABLE_ERROR_DELETE" PortErrorLoad = "PORTABLE_ERROR_LOAD" PortErrorSearch = "PORTABLE_ERROR_SEARCH" PortErrorParam = "PORTABLE_ERROR_PARAM" PortErrorValidation = "PORTABLE_ERROR_VALIDATION" PortErrorScript = "PORTABLE_ERROR_SCRIPT" PortErrorDescriptor = "PORTABLE_ERROR_DESCRIPTOR" PortErrorNotification = "PORTABLE_ERROR_NOTIFICATION" PortErrorConsumer = "PORTABLE_ERROR_CONSUMER" PortErrorProducer = "PORTABLE_ERROR_PRODUCER" PortErrorCore = "PORTABLE_ERROR_CORE" PortErrorHandler = "PORTABLE_ERROR_HANDLER" PortErrorAccess = "PORTABLE_ERROR_ACCESS" PortErrorPermission = "PORTABLE_ERROR_PERMISSION" PortErrorAuth = "PORTABLE_ERROR_AUTH" PortErrorMigration = "PORTABLE_ERROR_MIGRATION" PortErrorType = "PORTABLE_ERROR_TYPE" PortErrorFunction = "PORTABLE_ERROR_FUNCTION" PortErrorEncoder = "PORTABLE_ERROR_ENCODER" PortErrorDecoder = "PORTABLE_ERROR_DECODER" PortErrorReader = "PORTABLE_ERROR_READER" PortErrorWriter = "PORTABLE_ERROR_WRITER" PortErrorCloser = "PORTABLE_ERROR_CLOSER" PortErrorTemplate = "PORTABLE_ERROR_TEMPLATE" PortErrorCommand = "PORTABLE_ERROR_COMMAND" PortErrorProcess = "PORTABLE_ERROR_PROCESS" PortErrorIO = "PORTABLE_ERROR_IO" PortErrorRender = "PORTABLE_ERROR_RENDER" PortErrorState = "PORTABLE_ERROR_STATE" PortErrorMemory = "PORTABLE_ERROR_MEMORY" PortErrorNetwork = "PORTABLE_ERROR_NETWORK" PortErrorDevice = "PORTABLE_ERROR_DEVICE" PortErrorRecursion = "PORTABLE_ERROR_RECURSION" PortErrorArgument = "PORTABLE_ERROR_ARGUMENT" PortErrorBody = "PORTABLE_ERROR_BODY" PortErrorHeader = "PORTABLE_ERROR_HEADER" PortErrorProtocol = "PORTABLE_ERROR_PROTOCOL" PortErrorSize = "PORTABLE_ERROR_SIZE" PortErrorPriority = "PORTABLE_ERROR_PRIORITY" PortErrorCondition = "PORTABLE_ERROR_CONDITION" PortErrorIteration = "PORTABLE_ERROR_ITERATION" PortErrorParser = "PORTABLE_ERROR_PARSER" PortErrorEnvelop = "PORTABLE_ERROR_ENVELOP" PortErrorEnvironment = "PORTABLE_ERROR_ENVIRONMENT" )
Variables ¶
This section is empty.
Functions ¶
func IsEnumValid ¶ added in v1.10.0
IsEnumValid In list validation rule
func IsRangeValid ¶ added in v1.10.0
IsRangeValid Range list validation rule
func IsRegularValid ¶ added in v1.10.0
IsRegularValid check regular expression
func IsRequiredValid ¶ added in v1.10.0
IsRequiredValid Required validation rule
func PrepareActualValidationRules ¶ added in v1.10.0
func PrepareActualValidationRules(customValidationRules map[string]ValidationCallback)
PrepareActualValidationRules func to append basicValidationRules or replace some one rules customValidationRules If you want to use your own validation rules add the rules in to customValidationRules var
Types ¶
type ErrorData ¶
type ErrorData struct { Message string // Error message Code interface{} // Code message Name string // Name of detail }
ErrorData Detailed error
type IError ¶
type IError interface { Code(code interface{}) IError // Set error code Error() string // Error interface std FlushDetails() IError // Reset all details GetCode() interface{} // Get error code GetDetails() []IError // Get error details GetHTTP() int // Get http code HTTP(httpCode int) IError // Set HTTP code IfDetails() IError // Return error if error has details else nil MergeDetails(e ...IError) IError // Merge detail to error Origin() *PortError // Get portable error PopDetail() IError // Get detail from PushDetail(code interface{}, name string, message string) IError // Add error detail }
IError Common Error Interface
func HttpValidationError ¶ added in v1.10.3
HttpValidationError prepare validation error with 400 http code
func NewFWithName ¶
New error with name
func NewWithName ¶
New error with name
func ValidateStruct ¶ added in v1.10.0
func ValidateStruct(v interface{}) IError
ValidateStruct struct fields validation
type PortError ¶
type PortError struct { ErrorData // Error data // contains filtered or unexported fields }
PortError Portable error
func (*PortError) GetCode ¶ added in v1.7.0
func (e *PortError) GetCode() interface{}
Get Error Code
func (*PortError) GetDetails ¶
Interface error get details
func (*PortError) MergeDetails ¶ added in v1.8.0
Merge detail from other errors
func (*PortError) PushDetail ¶
Interface error push detail
func (*PortError) UnmarshalJSON ¶
Unmarshal error
type ValidationCallback ¶ added in v1.10.0
ValidationCallback function that performs validation rule
type ValidationRule ¶ added in v1.10.0
ValidationRule validation params
func ParseValidTag ¶ added in v1.10.0
func ParseValidTag(validTag string) []ValidationRule
ParseValidTag parse validation tag for rule and arguments Example valid:"exp~[0-5]+;range~1-50;enum~5,10,15,20,25"`