@bitcointrade/react-validity
Advanced tools
Comparing version 2.1.0 to 2.2.0
export declare type ValidationFn = (value: string) => boolean; | ||
export declare type ValidationNumericFn = (value: number) => boolean; | ||
export declare function optional(fn: ValidationFn): (value: string) => boolean; | ||
export declare function trim(fn: ValidationFn): (value: string) => boolean; | ||
export declare function formattedStrToNumber(locale: string): (fn: ValidationNumericFn) => (value: string) => boolean; |
@@ -11,2 +11,19 @@ "use strict"; | ||
exports.trim = trim; | ||
function formattedStrToNumber(locale) { | ||
return function (fn) { | ||
return function (value) { | ||
var formattedNumber = new Intl.NumberFormat(locale, { | ||
maximumFractionDigits: 1, | ||
minimumFractionDigits: 1, | ||
}) | ||
.format(0); | ||
var decimalSeparatorChar = formattedNumber.replace(/\d/g, ""); | ||
var parsedValue = +value | ||
.replace(new RegExp("[^\\d" + decimalSeparatorChar + "]", "g"), "") | ||
.replace(decimalSeparatorChar, "."); | ||
return fn(parsedValue); | ||
}; | ||
}; | ||
} | ||
exports.formattedStrToNumber = formattedStrToNumber; | ||
//# sourceMappingURL=factories.js.map |
{ | ||
"name": "@bitcointrade/react-validity", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"repository": "git@github.com:cryptocurrencytrader/react-validity.git", | ||
@@ -5,0 +5,0 @@ "author": "Rafael Tavares <rafael@tavares.email>", |
@@ -1,4 +0,4 @@ | ||
export declare function greaterThan(comparisonValue: number): (value: string) => boolean; | ||
export declare function greaterThanOrEqual(comparisonValue: number): (value: string) => boolean; | ||
export declare function lessThan(comparisonValue: number): (value: string) => boolean; | ||
export declare function lessThanOrEqual(comparisonValue: number): (value: string) => boolean; | ||
export declare function greaterThan(comparisonValue: number, locale: string): (value: string) => boolean; | ||
export declare function greaterThanOrEqual(comparisonValue: number, locale: string): (value: string) => boolean; | ||
export declare function lessThan(comparisonValue: number, locale: string): (value: string) => boolean; | ||
export declare function lessThanOrEqual(comparisonValue: number, locale: string): (value: string) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var factories_1 = require("../factories"); | ||
function greaterThan(comparisonValue) { | ||
return factories_1.trim(factories_1.optional(function (value) { return +value > comparisonValue; })); | ||
function greaterThan(comparisonValue, locale) { | ||
return factories_1.trim(factories_1.optional(factories_1.formattedStrToNumber(locale)(function (value) { return value > comparisonValue; }))); | ||
} | ||
exports.greaterThan = greaterThan; | ||
function greaterThanOrEqual(comparisonValue) { | ||
return factories_1.trim(factories_1.optional(function (value) { return +value >= comparisonValue; })); | ||
function greaterThanOrEqual(comparisonValue, locale) { | ||
return factories_1.trim(factories_1.optional(factories_1.formattedStrToNumber(locale)(function (value) { return value >= comparisonValue; }))); | ||
} | ||
exports.greaterThanOrEqual = greaterThanOrEqual; | ||
function lessThan(comparisonValue) { | ||
return factories_1.trim(factories_1.optional(function (value) { return +value < comparisonValue; })); | ||
function lessThan(comparisonValue, locale) { | ||
return factories_1.trim(factories_1.optional(factories_1.formattedStrToNumber(locale)(function (value) { return value < comparisonValue; }))); | ||
} | ||
exports.lessThan = lessThan; | ||
function lessThanOrEqual(comparisonValue) { | ||
return factories_1.trim(factories_1.optional(function (value) { return +value <= comparisonValue; })); | ||
function lessThanOrEqual(comparisonValue, locale) { | ||
return factories_1.trim(factories_1.optional(factories_1.formattedStrToNumber(locale)(function (value) { return value <= comparisonValue; }))); | ||
} | ||
exports.lessThanOrEqual = lessThanOrEqual; | ||
//# sourceMappingURL=number.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28060
361