Brijesh's Git Server — argus-core @ 7fe70b23373de45a57bafd87ca06a5688da4c3f6

Logging service

internal/applications/validation.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
package applications

import (
	pb "argus-core/rpc/applications"
	"fmt"
)

func validateCreateApplicationRequest(req *pb.CreateApplicationRequest) error {
    if req.Name == "" {
        return fmt.Errorf("name is required")
    }
    if len(req.Name) > 255 {
        return fmt.Errorf("name must be less than 256 characters")
    }
    if len(req.Description) > 1000 {
        return fmt.Errorf("description must be less than 1000 characters")
    }
    return nil
}

func validateUpdateApplicationRequest(req *pb.UpdateApplicationRequest) error {
    if req.ApplicationId == "" {
        return fmt.Errorf("application ID is required")
    }
    if req.Name == "" {
        return fmt.Errorf("name is required")
    }
    if len(req.Name) > 255 {
        return fmt.Errorf("name must be less than 256 characters")
    }
    if len(req.Description) > 1000 {
        return fmt.Errorf("description must be less than 1000 characters")
    }
    return nil
}