Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/AndrewHany/assertions

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/AndrewHany/assertions

  • v1.0.13
  • Source
  • Go
  • Socket score

Version published
Created
Source

assertions

Assertion style package, supporting custom assertions

GoDoc

This package is build on top of github.com/smarty/assertions package

it allows custom assertions on fields and types

you basically do

	customAssertions := map[string]assertions.AssertionFunc{
		"$.Field1.Field2":   assertions.SkipAssertion,
		assertion.TimeType:  assertions.AssertTimeToDuration(time.Second),
		assertion.FloatType: assertions.AssertFloat64ToDecimalPlaces(2),
		"$.Field1[][]":      customAssertionFunc,
	}

and pass this assertion map to the assert function For example

  • "$.Field1.Field2": assertions.SkipAssertion, references nested fields in root struct, and skips assertion
  • assertion.TimeType: assertions.AssertTimeToDuration(time.Second) asserts till seconds (skip milliesconds)
  • assertion.FloatType: assertions.AssertFloat64ToDecimalPlaces(2) asserts till the first 2 decimal places
  • "$.Field1[][]": customAssertionFunc Or you can build your custom assertion method

FAQs

Package last updated on 25 Oct 2024

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