Develop ultra fast with Prismane 🎉

lowercase

This validator checks if a string has only lowercase characters.

Basic Usage

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

console.log(lowercase("martinpetrov")); // Will return null
console.log(lowercase("MartinPetrov")); // Will return an error`

useForm Hook Usage

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

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

API

Parameters

NameTypeDescription
valuenumberThe number 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.