MCPcopy Create free account
hub / github.com/Permify/permify / validate

Method validate

pkg/pb/base/v1/service.pb.validate.go:4575–4695  ·  view source on GitHub ↗
(all bool)

Source from the content-addressed store, hash-verified

4573}
4574
4575func (m *SchemaPartialWriteRequest) validate(all bool) error {
4576 if m == nil {
4577 return nil
4578 }
4579
4580 var errors []error
4581
4582 if len(m.GetTenantId()) > 128 {
4583 err := SchemaPartialWriteRequestValidationError{
4584 field: "TenantId",
4585 reason: "value length must be at most 128 bytes",
4586 }
4587 if !all {
4588 return err
4589 }
4590 errors = append(errors, err)
4591 }
4592
4593 if !_SchemaPartialWriteRequest_TenantId_Pattern.MatchString(m.GetTenantId()) {
4594 err := SchemaPartialWriteRequestValidationError{
4595 field: "TenantId",
4596 reason: "value does not match regex pattern \"^([a-zA-Z0-9_\\\\-@\\\\.:+]{1,128}|\\\\*)$\"",
4597 }
4598 if !all {
4599 return err
4600 }
4601 errors = append(errors, err)
4602 }
4603
4604 if m.GetMetadata() == nil {
4605 err := SchemaPartialWriteRequestValidationError{
4606 field: "Metadata",
4607 reason: "value is required",
4608 }
4609 if !all {
4610 return err
4611 }
4612 errors = append(errors, err)
4613 }
4614
4615 if all {
4616 switch v := interface{}(m.GetMetadata()).(type) {
4617 case interface{ ValidateAll() error }:
4618 if err := v.ValidateAll(); err != nil {
4619 errors = append(errors, SchemaPartialWriteRequestValidationError{
4620 field: "Metadata",
4621 reason: "embedded message failed validation",
4622 cause: err,
4623 })
4624 }
4625 case interface{ Validate() error }:
4626 if err := v.Validate(); err != nil {
4627 errors = append(errors, SchemaPartialWriteRequestValidationError{
4628 field: "Metadata",
4629 reason: "embedded message failed validation",
4630 cause: err,
4631 })
4632 }

Callers 2

ValidateMethod · 0.95
ValidateAllMethod · 0.95

Calls 6

GetTenantIdMethod · 0.95
GetMetadataMethod · 0.95
GetPartialsMethod · 0.95
ValidateAllMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected