nonNullableAsync

Creates a non nullable schema.

This schema function can be used to override the behavior of nullableAsync.

const Schema = v.nonNullableAsync<TWrapped, TMessage>(wrapped, message);

Generics

Parameters

  • wrapped TWrapped
  • message TMessage

Explanation

With nonNullableAsync the validation of your schema will not pass null inputs. If the input is null, you can use message to customize the error message.

Returns

Examples

The following examples show how nonNullableAsync can be used.

Unique username schema

Schema to validate a non-null unique username.

import { isUsernameUnique } from '~/api';

const UniqueUsernameSchema = v.nonNullableAsync(
  // Assume this schema is from a different file and reused here.
  v.nullableAsync(
    v.pipeAsync(
      v.string(),
      v.nonEmpty(),
      v.checkAsync(isUsernameUnique, 'The username is not unique.')
    )
  )
);

The following APIs can be combined with nonNullableAsync.

Schemas

Methods

Actions

Utils

Async

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of fabian-hiller
  • GitHub profile picture of EltonLobo07

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of Thanaen
  • GitHub profile picture of osdiab
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of F0rce
  • GitHub profile picture of fabulousgk
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of andrew-d-jackson
  • GitHub profile picture of dslatkin