Validating doubles/floats for pricing


Hi guys,

Is anyone validating doubles? If you mind sharing how?

I’m attempting to validate a number in this format 50.99.
Indicative, the package behind validator, doesn’t seem to have a validator for it. Also I noticed that the number rule doesn’t work.


In the interim I’ve extended the Validator

If anyone needs this…

  const doubleFn = async (data, field, message, args, get) => {
    const value = get(data, field)

    if (!value) {

    let double = value.match(/^\d+\.\d{0,2}$/g)

    if (!double) {
      throw message

  Validator.extend('double', doubleFn)