To define your validation rules, provide a Map
. Keys are field names, values are either a validation rule, or an array of validation rules.
// one rule
const rules = new Map([
['name', required]
])
// multiple rules
const rules = new Map([
function sleep(ms = 0) { | |
return new Promise(r => setTimeout(r, ms)) | |
} | |
async function run() { | |
await sleep(2000) | |
console.log('2s later') | |
} | |
run() |
// ngInject.js | |
function ngInject(func) { | |
if (func.ngInject)) { | |
func.$inject = func.ngInject() | |
} | |
return func | |
} | |
import ngInject from './ngInject' | |
export default function ngDirective(directive) { | |
let func = function(...injectedArgs) { | |
let link = (...directiveArgs) => new directive(...injectedArgs, ...directiveArgs) | |
return {...directive.ddo(), link} | |
} | |
func.$inject = ngInject(directive).$inject |
export default class SayingHelloComponent { | |
static ngInject() { | |
return [] // register your dependencies here (Angular 1 style, with string names) | |
} | |
static ddo() { | |
return { | |
bind: { | |
person: '@' | |
}, | |
name: 'sayingHello', // component's name |
export function ngBridged(name, deps) { | |
return ngBridge(angular.module(name, deps)) | |
} | |
export function ngBridge(ngModule) { | |
const register = (type, ...args) => ngBridge(ngModule[type](...args)) | |
const injectable = type => (name, injectableFunc) => register(type, name, ngInject(injectableFunc)) | |
const pass = type => (...args) => register(type, ...args) |
async function sleep(ms) { | |
return new Promise(r => setTimeout(r, ms)) | |
} | |
async function foo() { console.log('s foo'); await sleep(2000); console.log('d foo'); return 'foo'; } | |
async function bar() { console.log('s bar'); await sleep(1000); console.log('d bar'); return 'bar'; } | |
async function baz() { console.log('s baz'); await sleep(2000); console.log('d baz'); return 'baz'; } | |
async function run() { | |
console.log('start') |
@ngInject('bus', '$ionicModal') | |
class Adder { | |
constructor(num) { | |
this.num = num | |
} | |
// order matters | |
// if you @swallow first, then @log won't log caught exceptions | |
@log | |
@swallow |
<?php | |
namespace param { | |
class QueryParam { | |
const SINGLE = 'single'; | |
const MANY = 'many'; | |
const MANY_CSV = 'csv'; | |
public $queryField; | |
private $nullable = false; |
jQuery("ul.popover.level0").menuAim({ | |
activate: function(row) { jQuery(row).addClass('active') }, | |
deactivate: function(row) { jQuery(row).removeClass('active') }, | |
rowSelector: 'li.level1.parent', | |
exitMenu: function() { return true; } | |
}); |
To define your validation rules, provide a Map
. Keys are field names, values are either a validation rule, or an array of validation rules.
// one rule
const rules = new Map([
['name', required]
])
// multiple rules
const rules = new Map([