UNPKG

osmos

Version:

OSMOS - Symbiosys

30 lines (25 loc) 760 B
import { ValidationRules } from 'aurelia-validation'; export class CustomValidationRules { set() { ValidationRules.customRule( 'max', (value, obj, min) => { if (value === null || value === undefined) return true; let float = parseFloat(value); return float <= min; }, `\${$displayName} must be an inferior to \${$config.min}`, min => ({ min }) ); ValidationRules.customRule( 'min', (value, obj, max) => { if (value === null || value === undefined) return true; let float = parseFloat(value); return float >= max; }, `\${$displayName} must be an superior to \${$config.max}`, max => ({ max }) ); } }