How to use the validator.isFloat function in validator

To help you get started, we’ve selected a few validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Caltech-IPAC / firefly / src / firefly / js / visualize / draw / ShapeDataObj.js View on Github external
}

    const {fontName, fontSize, fontWeight, fontStyle}= drawParams;
    const color = drawParams.color || drawObj.color || 'black';

    const devicePt= plot.getDeviceCoords(inPt);

    //if (!plot.pointOnDisplay(devicePt)) {
    if (!devicePt) {
        return false;
    }

    let {x,y}= devicePt;

    let textHeight= 12;
    if (validator.isFloat(fontSize.substring(0, fontSize.length - 2))) {
        textHeight = parseFloat(fontSize.substring(0, fontSize.length - 2)) * 14 / 10;
    }


    const textWidth = textHeight*text.length*8/20;
    if (textOffset) {
        x+=textOffset.x;
        y+=textOffset.y;
    }


    if (x<2) {
        if (x<=-textWidth) return false; // don't draw
        x = 2;
    }
    if (y<2) {
github Caltech-IPAC / firefly / src / firefly / js / visualize / region / RegionFactory.js View on Github external
// further investigated)
                    isTransformationChecked = true;
                    break;
                case 'i':
                    unit = RegionValueUnit.IMAGE_PIXEL;
                    break;
                default:
                    unit = RegionValueUnit.CONTEXT;
            }
            nstr = vstr.substring(0, vstr.length-1);
        } else {
            nstr = vstr.slice();
        }

        // check if the string is a valid float number (including integer)
        if (!validator.isFloat(nstr)) {
            var ret;

            if (vType) {
                ret = this.parseCoordinates(nstr, coordSys, vType);
            }
            if (ret) {
                nstr = ret.toString();
                unit = RegionValueUnit.DEGREE;
            } else {
                return null;
            }
        }

        var val = parseFloat(nstr);
        return {unit, val, isTransformationChecked};
    }
github Caltech-IPAC / firefly / src / firefly / js / visualize / region / RegionFactory.js View on Github external
var ops = option ? option : makeRegionOptions({});
        const features = ptStr.split(/\s+/);

        if (has(option, regionPropsList.PTTYPE)) {
            unset(option, regionPropsList.PTTYPE);
        }
        if (has(option, regionPropsList.PTSIZE)) {
            unset(option, regionPropsList.PTSIZE);
        }
        if (features.length >= 1) {
            var pType = getRegionPointType(features[0]);

            if ( pType && pType !== RegionPointType.undefined ) {
                if (features.length === 1) {
                    set(ops, regionPropsList.PTTYPE, pType);
                } else if (validator.isFloat(features[1])) {
                    var s;

                    if (pType === RegionPointType.arrow) {
                        s = parseInt(parseFloat(features[1])+0.5);
                    } else {
                        s = parseInt(parseFloat(features[1]) + 0.5) / 2;
                    }

                    set(ops, regionPropsList.PTSIZE, s);
                    set(ops, regionPropsList.PTTYPE, pType);
                }
            }
        }
        return ops;
    }
github Caltech-IPAC / firefly / src / firefly / js / visualize / draw / ShapeDataObj.js View on Github external
export function fontHeight (fontSize) {
    let height = 12;

    if (validator.isFloat(fontSize.substring(0, fontSize.length-2))) {
        height = parseFloat(fontSize.substring(0, fontSize.length-2)) * 14/10 + 0.5;
    }
    return height;
}
github marcocesarato / react-native-input-validator / src / InputValidator.js View on Github external
}
                break;
            case "numeric":
                if (!this.isNumeric(text) && !validator.isNumeric(text)) {
                    is_valid = false;
                }
                break;
            case "integer":
            case "int":
                if (!this.isNumeric(text) && !validator.isNumeric(text)) {
                    is_valid = false;
                }
                break;
            case "real":
            case "float":
                if (!this.isNumeric(text) && !validator.isFloat(text)) {
                    is_valid = false;
                }
                break;
            case "decimal":
                if (!this.isNumeric(text) && !validator.isDecimal(text)) {
                    is_valid = false;
                }
                break;
            case "alpha":
                if (!validator.isAlpha(text)) {
                    is_valid = false;
                }
                break;
            case "alphanumeric":
                if (!validator.isAlphanumeric(text)) {
                    is_valid = false;
github bradwestfall / house-rules / src / rules / Numeric.js View on Github external
minMaxChecker(value, rules) {
    if (validator.isInt(value)) {
      return validator.isInt(value, rules)
    } else if (validator.isFloat(value)) {
      return validator.isFloat(value, rules)
    }
  }
github marcocesarato / react-native-input-validator / src / InputText.js View on Github external
}
                break;
            case "numeric":
                if (!this.isNumeric(text) && !validator.isNumeric(text)) {
                    is_valid = false;
                }
                break;
            case "integer":
            case "int":
                if (!this.isNumeric(text) && !validator.isNumeric(text)) {
                    is_valid = false;
                }
                break;
            case "real":
            case "float":
                if (!this.isNumeric(text) && !validator.isFloat(text)) {
                    is_valid = false;
                }
                break;
            case "decimal":
                if (!this.isNumeric(text) && !validator.isDecimal(text)) {
                    is_valid = false;
                }
                break;
            case "alpha":
                if (!validator.isAlpha(text)) {
                    is_valid = false;
                }
                break;
            case "alphanumeric":
                if (!validator.isAlphanumeric(text)) {
                    is_valid = false;
github ajainvivek / react-aztec / src / helpers / validation.js View on Github external
float(value, options) {
    return validator.isFloat(value, options);
  },
  ip(value, version) {