Code Monkey home page Code Monkey logo

enforcer's Introduction

👋 Hi, I'm Rojan

Software Engineer and Writer

rrojan

- 🔭 Currently working as a Senior Full-stack Engineer at Outside and as part-time teaching faculty at Kings College Nepal

- 💬 Working with Go, Typescript, JavaScript, Ruby, React, NextJS and NodeJS

- 📫 Reach me at: [email protected], [email protected]

Connect with me:

rojan-rajbhandari  @rrojan

Languages and Tools:

javascript   typescript go  nodejs  ruby  python 

react   nextjs   django   rails   gin framework   express js   docker   aws   gcp   firebase   graphql   linux   rabbitMQ   git

Github stats

enforcer's People

Contributors

rrojan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

enforcer's Issues

Add support for verbose error details

Normally we have errors like

[]string{
    "Required field 'Name' is not provided",
    "Age must be greater than 18"
}

However this does not support custom error messages.

Providing "resourceType" and "failed" allows us to create custom error messages, both on the frontend and backend.

[]enforcer.Failed {
    enforcer.Failed{
        ResourceType: "name",
        Failed: "required",
    },
    enforcer.Failed{
        ResourceType: "age",
        Failed: "min:18",
    },
}

Then you can create custom error messages for any language like

// utils/generateErrorMessage.js


function generateErrorMessage(resource, failed) {
    return "Appropriate error from failed"
}

Add support for default and beforeValidate

Suggested by @Znerf

Feature request for setting default value or processing the value from the enforcer tag

type Post struct {
  title               string
  category      string         `enforce:"default:uncategorized"`
  dateAdded  time.Time  `enforce:"beforeValidate:setTimeNow"`
}

func setTimeNow() {
  return time.Now()
}

p := Post{ ... }
errors := enforcer.Validate(p)

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.