New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/posteris/custom-validate

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/posteris/custom-validate

  • v1.4.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

Custom validate

CI Go Reference GitHub license GitHub release

Project dedicated to stadardize some patterns like erros and validations that can be utils and shared by many others projects.

The next sessions was dedicated to show how to use each features.

Validation

The validation model receives a model (struct) that contains the validation tag, in case of some validation fail the return will be a ValidationError array, other else nil.

import commom "github.com/posteris/commons/validation"

//define struct model
type User struct {
	Name    string `validate:"required,min=3,max=256"`
	Surname string `validate:"required,min=3,max=256"`
	Email   string `validate:"omitempty,email"`
}

//create a model based on struct
userModel := User{
    Surname: "da Silva"
    Email: "dasilva@gmail.com"
}

err := commom.ValidateModel(userModel)

Errors

in this package you can use the follow two errors:

  • DefaultError
  • ValidationError

The default error generate an interface containing just one field Message.

import commom "github.com/posteris/commons/errors"

err := commom.CreateDefaultError("some error message")

The validationError is formed by the fields Field: and Message: and can be created as showed below.

import commom "github.com/posteris/commons/errors"

err := commom.CreateValidationError("field-name", "some error message")

Query Parameter

The Query parameter module has a set of functions to help us to parse query parameters. These functions are listed below:

  • IsAsyncRequest

The IsAsyncRequest allow us to ask if the request should be solved by sync or async way. It's simple to use and can be explained below

async := IsAsyncRequest(fiberCtx)

Software Quality

Quality Gate Status Maintainability Rating Coverage Security Rating Vulnerabilities

This lib use Sonarcloud to help understend the code quality and security.

In conjunction with Sonarcloud, this lib uses Horusec which blocks CI/CD in any vulnerability incidence

Benchmark

Thinking in the software quality, the benchmark regression was created. It's can be viewed at the link bellow.

Performance Regeression

FAQs

Package last updated on 08 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc