@nestjsi/class-validator

Additions for class validator

Usage no npm install needed!

<script type="module">
  import nestjsiClassValidator from 'https://cdn.skypack.dev/@nestjsi/class-validator';
</script>

README

Class Validator

Class Validator

NestJS specific additions for TypeStack Class Validator and ValidatorJS.

NPM Version NPM Downloads TypeScript Typings

Reference

@FixedLength

Checks if the string's length is not less or more than given number.

@FixedLength(
  fixedLength, // number
  validationOptions, // ValidationOptions
)

@InRange

Checks if a value is in a range of values.

@InRange(
  minValue, // number
  maxValue, // number
  maxDecimalPlaces, // number
  validationOptions, // ValidationOptions
)

@IsDiscount

Checks if a value is in a range of values with two decimal places.

@IsDiscount(
  validationOptions, // ValidationOptions
)

@IsEmailTidy

Checks if the string is an email.

@IsEmailTidy(
  options, // ValidatorJS.IsEmailOptions
  validationOptions, // ValidationOptions
)

@IsHTMLFree

Checks if the string has HTML tags.

@IsHTMLFree(
  validationOptions, // ValidationOptions
)

@IsNotBlankString

Checks if there is at least one character in the string. Removes whitespace from both ends of a string.

@IsNotBlankString(
  validationOptions, // ValidationOptions
)

@IsNotEmptyString

Checks if there is at least one character in the string. Considers the line is not empty even if it has trimmable characters.

@IsNotEmptyString(
  validationOptions, // ValidationOptions
)

@IsNotNull

Checks if given value is not null.

@IsNotNull(
  validationOptions, // ValidationOptions
)

@IsPrice

Checks if a value is in a range of values with two decimal places.

@IsPrice(
  validationOptions, // ValidationOptions
)

@IsSingleLine

Checks if there are line breaks in the text.

@IsSingleLine(
  validationOptions, // ValidationOptions
)

@IsStringDate

Is string in 'YYYY-MM-DD' format.

@IsStringDate(
  validationOptions, // ValidationOptions
)

@IsUUID4

Checks if the string is a UUID version 4.

@IsUUID4(
  validationOptions, // ValidationOptions
)

@MinMax

Checks if a value is in a range of values.

@MinMax(
  minValue, // number
  maxValue, // number
  validationOptions, // ValidationOptions
)

@MinMaxInt

Checks is value between two integers inclusive.

@MinMaxInt(
  minimumInteger, // number
  maximumInteger, // number
  validationOptions, // ValidationOptions
)

@MinMaxLength

Checks if the string's length is not less than given number.

@MinMaxLength(
  minLen, // number
  maxLen, // number
  validationOptions, // ValidationOptions
)

@MinMaxPct

Checks if a value is in a range of values with two decimal places.

@MinMaxPct(
  minValue, // number
  maxValue, // number
  validationOptions, // ValidationOptions
)

@Money

Checks if a value is in a range of values with two decimal places.

@MinMaxPct(
  maxValue, // number = 562949953421311
  minValue, // number = 0.01
  validationOptions, // ValidationOptions
)

See also

💾 My other projects

Open Source