Socket
Socket
Sign inDemoInstall

angular-validated-resource

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-validated-resource

JSON Schema validation for angular resource


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Angular Validated Resource

JSON Schema validation for angular resource.

build status npm version MIT license we're hiring

Usage

npm install angular-validated-resource

Designed to be an (almost) drop-in replacement for angular resource. When you configure the resource actions, additionally pass a schema to queryParamsSchema, requestBodySchema, or responseBodySchema to automatically validate on every request.

angular.module 'Product', [
  require 'angular-validated-resource'
]

.factory 'Product', ngInject (validatedResource) ->
  validatedResource 'http://api.test.com/products/:_id', {_id: '@_id'},
    query:
      method: 'GET'
      isArray: true
      queryParamsSchema: require './product_schemas/query/query_params.json'
      requestBodySchema: require './product_schemas/query/request_body.json'
      responseBodySchema: require './product_schemas/query/response_body.json'
    move:
      method: 'POST'
      url: 'http://api.test.com/products/:_id/move'
      queryParamsSchema: require './product_schemas/move/query_params.json'
      requestBodySchema: require './product_schemas/move/request_body.json'
      responseBodySchema: require './product_schemas/move/response_body.json'

If window.env is 'test', validation will not allow unknown fields. Otherwise, validation will allow unknown fields.

Although not required, we strongly recommended that you validate all parts of the request (queryParams, requestBody, and responseBody) for every action, even if the validation is just checking for an empty object. This way, you will catch any unexpected data that you pass through.

Contributing

Please follow our Code of Conduct when contributing to this project.

$ git clone https://github.com/goodeggs/angular-validated-resource && cd angular-validated-resource
$ npm install
$ npm test

Module scaffold generated by generator-goodeggs-npm.

Keywords

FAQs

Package last updated on 26 Jul 2015

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