@@ -2,7 +2,7 @@ defmodule Systemd.UnitFile.Validator do
22 @ moduledoc false
33
44 alias Systemd.UnitFile
5- alias Systemd.UnitFile . { Directive , Section , ValidationError , Value }
5+ alias Systemd.UnitFile . { Directive , Section , ValidationError , Value , ValueParser }
66
77 @ known_sections % {
88 "service" => MapSet . new ( [ "Unit" , "Service" , "Install" ] ) ,
@@ -273,10 +273,8 @@ defmodule Systemd.UnitFile.Validator do
273273 one_of ( section , directive , String . downcase ( value ) , ~w( 1 yes true on 0 no false off) , span )
274274 end
275275
276- defp duration ( _section , _directive , "infinity" , _span ) , do: [ ]
277-
278276 defp duration ( section , directive , value , span ) do
279- if String . match ?( value , ~r / ^ \d +( \. \d +)? \s *(us|µs|ms|s|sec|m|min|h|hr|d|day|w|week)?$ / ) do
277+ if ValueParser . duration ?( value ) do
280278 [ ]
281279 else
282280 [
@@ -292,7 +290,7 @@ defmodule Systemd.UnitFile.Validator do
292290 end
293291
294292 defp octal_mode ( section , directive , value , span ) do
295- if String . match ?( value , ~r / ^[0-7]{3,4}$ / ) do
293+ if ValueParser . octal_mode ?( value ) do
296294 [ ]
297295 else
298296 [ value_error ( section , directive , value , "expected an octal mode such as 0660" , span ) ]
0 commit comments