Develop ultra fast with Prismane 🎉

more

This validator checks if a number is more than a given number.

Basic Usage

import { more } from "@prismane/core/validators";

console.log(more(10, 0)); // Will return null
console.log(more(40, 50)); // Will return an error`

useForm Hook Usage

function Demo() {
  const { handleSubmit, handleReset, register } = useForm({
    fields: {
      age: {
        value: 14,
        validators: {
          more: (v: any) => more(v, 13),
        },
      },
    },
  });

  return (
    <Form
      onSubmit={(e: any) => {
        handleSubmit(e, (v: any) => console.log(v));
      }}
      onReset={() => handleReset()}
      maw={300}
    >
      <NumberField
        placeholder="Enter age: "
        label="Age:"
        {...register("age")}
      />
      <Button type="submit">Submit</Button>
    </Form>
  );
}

API

Parameters

NameTypeDescription
valuenumberThe number that will be validated.
numbernumberThe number that will be compared.
fieldNamestring / undefinedThe name of the field.