Adds a format to verify MAC addresses to JSONSchema.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
+register_format('mac-addr', \&pve_verify_mac_addr);
+sub pve_verify_mac_addr {
+ my ($mac_addr, $noerr) = @_;
+
+ if ($mac_addr !~ m/^[0-9a-f]{2}(:[0-9a-f]{2}){5}$/i) {
+ return undef if $noerr;
+ die "value does not look like a valid MAC address\n";
+ }
+ return $mac_addr;
+}
+
register_format('ipv4', \&pve_verify_ipv4);
sub pve_verify_ipv4 {
my ($ipv4, $noerr) = @_;
register_format('ipv4', \&pve_verify_ipv4);
sub pve_verify_ipv4 {
my ($ipv4, $noerr) = @_;