Skip to content

Instantly share code, notes, and snippets.

@miloandmilk
miloandmilk / salesforceId.js
Created November 15, 2017 16:56 — forked from knation/salesforceId.js
JavaScript Salesforce ID Check & Expansion
/**
* The regex for a SF ID.
* @type {RegExp}
* @const
*/
var ID_REGEX = /^[0-9a-zA-Z]{15}([0-9a-zA-Z]{3})?$/;
/**
* Array used to expand a SF ID from 15 to 18 characters.
* @type {Array.<String>}
/**
* getDependentPicklistOptions
* by Benj Kamm, 2012
* (inspired by http://iwritecrappycode.wordpress.com/2012/02/23/dependent-picklists-in-salesforce-without-metadata-api-or-visualforce/)
* CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/us/)
*
* Build an Object in which keys are valid options for the controlling field
* and values are lists of valid options for the dependent field.
*
* Method: dependent PickListEntry.validFor provides a base64 encoded
@miloandmilk
miloandmilk / joi-query-string.js
Last active December 21, 2015 22:39
Generate query string from an object that will work with HAPI/Joi validation on arrays - even if the array only has a single element.
// Copyright Sean Kemplay 2013
// License MIT
var appendParams = function (memo, values, key, list) {
params = memo;
// Cover off use cases
if (values) {
if (values.constructor === Array && values.length > 0) {
for (var i = 0; i < values.length; i++) {
if (i > 0) {
@miloandmilk
miloandmilk / app.js
Last active September 9, 2022 00:22 — forked from hagino3000/app.js
/**
* Module dependencies.
*/
var express = require('express');
var rpcMethods = require('./methods.js');
var app = module.exports = express.createServer();
// Configuration