Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Clean validated data #43

@jede

Description

@jede

It would be great to use validate to clean the data a user sends in. Basically I want a way to whitelist attributes to make them optional. So for a user you should be able to pass in description, but not createdAt. Here is a example of how it could work:

data = 
  name: 'Test'
  description: 'Yaay'
  createdAt: 'omgomg'

constraints =
  name:
    presence: true
  description: true

validate.async(data, constraints).then (params) =>
  # params won't contain createdAt
  User.create(params)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions