Git Product home page Git Product logo

mold's Introduction

Package mold

Project status Build Status Coverage Status Go Report Card GoDoc License

Package mold is a general library to help modify or set data within data structures and other objects.

How can this help me you ask, please see the examples here

Requirements

  • Go 1.18+

Installation

Use go get.

go get -u github.com/go-playground/mold/v4

Examples

Example Description
simple A basic example with custom function.
full A more real life example combining the usage of multiple packages.

Modifiers

These functions modify the data in-place.

Name Description
camel Camel Cases the data.
default Sets the provided default value only if the data is equal to it's default datatype value.
empty Sets the field equal to the datatype default value. e.g. 0 for int.
lcase lowercases the data.
ltrim Trims spaces from the left of the data provided in the params.
rtrim Trims spaces from the right of the data provided in the params.
set Set the provided value.
snake Snake Cases the data.
strip_alpha Strips all ascii characters from the data.
strip_alpha_unicode Strips all unicode characters from the data.
strip_num Strips all ascii numeric characters from the data.
strip_num_unicode Strips all unicode numeric characters from the data.
strip_punctuation Strips all ascii punctuation from the data.
title Title Cases the data.
tprefix Trims a prefix from the value using the provided param value.
trim Trims space from the data.
tsuffix Trims a suffix from the value using the provided param value.
ucase Uppercases the data.
ucfirst Upper cases the first character of the data.

Scrubbers

These functions obfuscate the specified types within the data for pii purposes.

Name Description
emails Scrubs multiple emails from data.
email Scrubs the data from and specifies the sha name of the same name.
text Scrubs the data from and specifies the sha name of the same name.
name Scrubs the data from and specifies the sha name of the same name.
fname Scrubs the data from and specifies the sha name of the same name.
lname Scrubs the data from and specifies the sha name of the same name.

Special Information

  • To use a comma(,) within your params replace use it's hex representation instead '0x2C' which will be replaced while caching.

Contributing

I am definitely interested in the communities help in adding more scrubbers and modifiers. Please send a PR with tests, and preferably no extra dependencies, at lease until a solid base has been built.

Complimentary Software

Here is a list of software that compliments using this library post decoding.

  • validator - Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving.
  • form - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.

License

Distributed under MIT License, please see license file in code for more details.

mold's People

Contributors

deankarn avatar frederikhors avatar jcconnell avatar nchelluri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.