feat(aa-log): minor improvment in rule generation & formatting.

This commit is contained in:
Alexandre Pujol 2024-09-26 22:15:46 +01:00
parent fbdf9cea64
commit 83bc7d3ade
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
7 changed files with 97 additions and 34 deletions

View file

@ -118,6 +118,21 @@ func (r *File) String() string {
}
func (r *File) Validate() error {
if !isAARE(r.Path) {
return fmt.Errorf("'%s' is not a valid AARE", r.Path)
}
for _, v := range r.Access {
if v == "" {
continue
}
if !slices.Contains(requirements[r.Kind()]["access"], v) ||
!slices.Contains(requirements[r.Kind()]["transition"], v) {
return fmt.Errorf("invalid mode '%s'", v)
}
}
if r.Target != "" && !isAARE(r.Target) {
return fmt.Errorf("'%s' is not a valid AARE", r.Target)
}
return nil
}
@ -260,6 +275,12 @@ func (r *Link) String() string {
}
func (r *Link) Validate() error {
if !isAARE(r.Path) {
return fmt.Errorf("'%s' is not a valid AARE", r.Path)
}
if !isAARE(r.Target) {
return fmt.Errorf("'%s' is not a valid AARE", r.Target)
}
return nil
}