sanival 0.0.2

A sanitization and validation library


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Sanival

A sanitization and validation library for D. It's also available as a package in the Dub package registry.

Sanival is not meant to be the sole or best way of validating and sanitizing data in a secure way. It's only meant to provide convenience tools for certain types of data validation and sanitization.

Installation

Using Dub, you may add sanival as dependency in your dub.json file and the package will be downloaded automatically during project build.

{
    ...
    "dependencies": {
        "sanival": "~>0.0.1"
    }
}

You may also fetch the latest version manually through the command-line:

dub fetch sanival

Usage

The savinal.validation module contains function and utilities for data validation whilst savinal.sanitization module is for sanitization.

import sanival.validation: isIPv4Address;

void main()
{
    string receivedIPAddress = "120.0.0.1";
	writeln(isIPv4Address(receivedIPAddress));

    // Using Universal Function Call Syntax (UFCS)
    writeln(receivedIPAddress.isIPv4Address());

    // Or even more simple
     writeln(receivedIPAddress.isIPv4Address);
}

Todo

The following are some of the functions implemented or yet to be implemented. You may make a feature request or submit a pull request of an implementation.

Validation

| Function | Description | Implemented | | --------------------------------------- | ---------------------------- | ----------- | | bool isIPAddress(string) | Both IPv4 and IPv6 | Yes | | bool isIPv4Address(string) | IPv4 | Yes | | bool isIPv6Address(string) | IPv6 | Yes | | bool isCreditCardNumber(string) | Credit card number | Yes | | bool isPostalAddress(string) | Postal address | Yes | | bool isUSZipCode(string) | US Zip code | Yes | | bool isSocialSecurityNumber(string) | Social Security Number | Yes | | bool isEmail(string) | Email address | No | | bool isNorthAmericanPhoneNumber(string) | North American phone number | Yes | | bool isPhoneNumber(string) | International phone number | No | | bool isDomainName(string) | Domain or sub-domain name | No | | bool isURL(string) | URL / URI | No | | bool isTelephoneCode(string) | International telephone code | No |

Sanitization

| Function | Description | Implemented | | ---------------------------------------------------- | ------------------------- | ----------- | | string stripTags(string input, string[] allowedTags) | Strips unwanted HTML tags | No |

Authors:
  • Lawrence Aberba
Dependencies:
none
Versions:
0.0.2 2018-Feb-03
0.0.1 2018-Feb-02
~master 2018-Feb-03
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 1 downloads total

Score:
0.4
Short URL:
sanival.dub.pm