Home

Awesome

            _ _     _       _   _             
/\   /\__ _| (_) __| | __ _| |_(_) ___  _ __  
\ \ / / _` | | |/ _` |/ _` | __| |/ _ \| '_ \ 
 \ V / (_| | | | (_| | (_| | |_| | (_) | | | |
  \_/ \__,_|_|_|\__,_|\__,_|\__|_|\___/|_| |_|

Validation

language:language language:Github Actions

A general purpose validation library for Deno.

Validators

This is the list of current validators

validatordescriptionexample
isAlphanumericchecks that a string only contains alphanumeric charactershello
isNumericchecks that a string only contains numeric characters123
isSpecialCharacterschecks that a string only contains special characters1/()£$%^"
isEmptychecks that a string is empty""
isTitlechecks to against Mr, Ms, Mrs, Miss, Dr, Rev, OtherDr
isNamechecks to see if name is validLayhey
isEmailchecks to see if email is validtest@test.com
isMaritalStatuschecks if string is a valid martial status single, married, civil partnered, divorced, widowedsingle
isUkMobileonly valid UK mobile numbers (exludes Isle of Man)07100900023
isUkPhoneonly valid UK phone numbers01603661068
isUkNationalInsuranceonly valid UK national insurance numbersSP939393H
isUkPostCodeonly valid UK postcodesNR12PD
isLetterAndSpacechecks to see if a string contains letters and spacesJim Layhey
isLetterAndSpaceAndNumberchecks to see if a string contains letters, spaces and numbersRandy Layhey 12
isNumberAndSpacechecks to see if a string contains numbers and spaces1 2 3
isFloatchecks to see if a string is a valid float1.5
isLengthchecks if string is between two valuesfoo, 1, 10
isBetweenchecks if number is between two values4, 0, 10
isGreaterThanchecks if number is greater than10, 4
isLessThanchecks if number is less than4, 10
isYesOrNochecks that a string is yes or noYes
isValidJSONchecks that a string is valid json{ "example": "pass" }
isIpV4checks that a string is a valid IP V4 address127.0.0.1
isIpV6checks that a string is a valid IP V6 address2001:0db8:85a3:0000:0000:8a2e:0370:7334
isUrlchecks that a string is a valid URLhttps://deno.land/
isDatechecks that a string is a valid Date2023-02-13, 2023/02/13
isDateDDMMYYYYchecks that a string is a valid Date DD-MM-YYYY19-12-1989

Usage

import { isName } from "https://raw.githubusercontent.com/ethandunford/deno-validation/main/src/validation.ts";

// true
console.log(isName("Layhey"))

// false
console.log(isName(String(1212)))

Testing

deno test src/tests/*.ts

License

Apache License 2.0

Version

2.0

Contributing

  1. Fork it (https://github.com/ethandunford/deno-validation/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors