Develop ultra fast with Prismane 🎉

uppercase

This validator checks if a string has only uppercase characters.

Basic Usage

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

console.log(uppercase("MARTINPETROV")); // Will return null
console.log(uppercase("martinpetrov")); // Will return an error`

useForm Hook Usage

function Demo() {
  const { handleSubmit, handleReset, register } = useForm({
    fields: {
      username: {
        value: "",
        validators: {
          uppercase: (v: string) => uppercase(v),
        },
      },
    },
  });

  return (
    <Form
      onSubmit={(e: any) => {
        handleSubmit(e, (v: any) => console.log(v));
      }}
      onReset={() => handleReset()}
      maw={300}
    >
      <TextField
        placeholder="eg. JOHNDOE"
        label="Username:"
        {...register("username")}
      />
      <Button type="submit">Submit</Button>
    </Form>
  );
}

API

Parameters

NameTypeDescription
valuestringThe string that will be validated.
regExpRegExp / undefinedAn optional parameter that will overwrite the default regex used to match the string.
fieldNamestring / undefinedThe name of the field.