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

@revmob/minimum-bid-validator

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@revmob/minimum-bid-validator

Revmob minimum bid validation utility

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
3
Weekly downloads
 
Created
Source

Minimum Bid Validator

Motivation

This module contains simple rules for minimum bid retrieval and validation for different countries and OSs.

Installation

npm install --save @revmob/minimum-bid-validator

Usage

// CommonJS:
const minimumBidValidator = require('@revmob/minimum-bid-validation').default

// or with ES6 modules:
import minimumBidValidator from '@revmob/minimum-bid-validation'

Public Interface

Methods
minimumBidValidator.setDefaultMinimumBid(defaults: BidInfo) => Void
minimumBidValidator.setAllBidsByCountry(bids: CountryBids) => Void
minimumBidValidator.getMinimumBid(os: String, countryList: String[]) => Number | undefined
minimumBidValidator.validate(os: String, countryList: String[], currentBid: Number) => Void, throws: Error
Types
interface BidInfo {
  [os: String]: Number
}

interface CountryBids {
  [countryCode: String]: BidInfo
}
Rules
getMinimumBid
  • If the country list contains invalid countries, only the valid ones are considered.
  • If there are no valid countries in the country list, returns the default minimum bid.
  • If the country list contains all countries set in setAllBidsByCountry, returns the default minimum bid.
  • If the OS is missing for one or more of the countries, it will not be considered.
  • If the OS is missing for all countries, returns undefined.
validate
  • If the country list contains invalid countries, only the valid ones are considered.
  • If there are no valid countries in the country list, uses the default minimum bid to validate.
  • If the country list contains all countries set in setAllBidsByCountry, uses the default minimum bid to validate.
  • If the OS is missing for one or more of the countries, it will not be considered.
  • If the OS is missing for all countries, always throws.

Example

// First setup...
const defaultBids = {
  'android': 1,
  'ios': 2
}

// Setting the default bids
minimumBidValidator.setDefaultMinimumBid(defaultBids)

// Setting the bids for each country
const bids = {
  BR: { 'android': 1, 'ios': 1 }
  US: { 'android': 2, 'ios': 2 }
  IN: { 'android': 0.5, 'ios': 0.75 }
}

minimumBidValidator.setAllBidsByCountry(bids)

// Then using...

// Getting the minimum bid for android in ['BR', 'US']
minimumBidValidator.getMinimumBid('android', ['BR', 'US']) // returns 2

// Validate if a given bid is greater than or equal the minimum bid
minimumBidValidator.validate('android', ['BR', 'US'], 1) // throws Error

FAQs

Package last updated on 23 Nov 2017

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