NAME

Data::Validate::DNS::NAPTR::Regexp - Validate the NAPTR Regexp field per RFC 2915

VERSION

version 0.002

SYNOPSIS

Functional API (uses globals!!):

use Data::Validate::DNS::NAPTR::Regexp;

my $regexp = '!test(something)!\\\\1!i';

if (is_naptr_regexp($regexp)) {
  print "Regexp '$regexp' is okay!"; 
} else {
  print "Regexp '$regexp' is invalid: " . naptr_regexp_error();
}

# Output:
# Regexp '!test(something)!\\1!i' is okay!

Object API:

use Data::Validate::DNS::NAPTR::Regexp ();

my $v = Data::Validate::DNS::NAPTR::Regexp->new();

my $regexp = '!test(something)!\\\\1!i';

if ($v->is_naptr_regexp($regexp)) {
  print "Regexp '$regexp' is okay!";
} else {
  print "Regexp '$regexp' is invalid: " . $v->naptr_regexp_error();
}

# Output:
# Regexp '!test(something)!\\1!i' is okay!

# $v->error() also works

DESCRIPTION

This module validates the Regexp field in the NAPTR DNS Resource Record as defined by RFC 2915.

It assumes that the data is in master file format and suitable for use in a ISC BIND zone file.

EXPORT

By default, "is_naptr_regexp" and naptr_regexp_error will be exported. If you're using the "OBJECT API", importing an empty list is recommended.

FUNCTIONAL API

Methods

is_naptr_regexp

is_naptr_regexp('some-string');

Returns a true value if the provided string is a valid Regexp for an NAPTR record. Returns false otherwise. To determine why a Regexp is invalid, see "naptr_regexp_error" below.

naptr_regexp_error

naptr_regexp_error();

Returns the last string error from a call to "is_naptr_regexp" above. This is only valid if "is_naptr_regexp" failed and returns a false value.

OBJECT API

This is the preferred method as the functional API uses globals.

Constructor

new

Data::Validate::DNS::NAPTR::Regexp->new(%args)

Currently no %args are available but this may change in the future.

is_naptr_regexp

$v->is_naptr_regexp('some-string');

See "is_naptr_regexp" above.

naptr_regexp_error

$v->naptr_regexp_error();

See "naptr_regexp_error" above.

error

$v->error();

See "naptr_regexp_error" above.

SEE ALSO

RFC 2915 - https://tools.ietf.org/html/rfc2915

AUTHOR

Matthew Horsfall (alh) - <wolfsage@gmail.com>

CREDITS

The logic for this module was adapted from ISC's BIND - https://www.isc.org/software/bind.

COPYRIGHT AND LICENSE

Copyright (C) 2013 Dyn, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.