-
Notifications
You must be signed in to change notification settings - Fork 2
Base64 Validatoins
Taqi ツ edited this page Oct 16, 2023
·
1 revision
Checks that it is a base64 string
[Base64String]
public string Base64 { get; set; }
Checks that the Base64 size does not exceed the specified value
Parameter | Type | Description |
---|---|---|
maxBase64Size | long |
Maximum Base64 size allowed |
unit | enum FileSizeUnit
|
File size unit (byte,Kilobyte,...) |
unitDisplayName | string? |
Base64 size unit to display in error message, If you pass null, it will show the FileSizeUnit in Error Message |
[MaxBase64Size(50,Enums.FileSizeUnit.Byte)]
public string Base64 { get; set; }
Checks that the base64 size is not less than the specified value
Parameter | Type | Description |
---|---|---|
minBase64Size | long |
Minimum Base64 size allowed |
unit | enum FileSizeUnit
|
File size unit (byte,Kilobyte,...) |
unitDisplayName | string? |
Base64 size unit to display in error message, If you pass null, it will show the FileSizeUnit in Error Message |
[MinBase64Size(50,Enums.FileSizeUnit.Byte)]
public string Base64 { get; set; }
Checks if the Base64 size is within the specified range
Parameter | Type | Description |
---|---|---|
maxBase64Size | long |
Maximum base64 size allowed |
minBase64Size | long |
Minimum base64 size allowed |
unit | enum FileSizeUnit
|
File size unit (byte,Kilobyte,...) |
unitDisplayName | string? |
File size unit to display in error message, If you pass null, it will show the FileSizeUnit in Error Message |
[RangeBase64Size(100,50,Enums.FileSizeUnit.Byte)]
public string Base64 { get; set; }
Checks that the ContentType
of the imported file is one of the allowed ContentTypes
Parameter | Type | Description |
---|---|---|
isExtension | bool |
If you want to enter the file extension instead of the content type |
allowedContentTypes | params string[]
|
Allowed content types (if you set isExtension to true, you can enter file extensions with dot and without dot) |
[AllowedBase64FileExtensions(false,new[] { "image/png","image/jpeg" })]
public string Base64 { get; set; }
[AllowedBase64FileExtensions(true,new[] { ".png","jpeg" })]
public string Base64 { get; set; }
Checks that the ContentType
of the imported file is not one of the illegal ContentTypes
.
Parameter | Type | Description |
---|---|---|
isExtension | bool |
If you want to enter the file extension instead of the content type |
notAllowedContentTypes | params string[]
|
Not allowed content types (if you set isExtension to true, you can enter file extensions with dot and without dot) |
[NotAllowedBase64FileExtensions(false,new[] { "image/png","image/jpeg" })]
public IFormFile? File { get; set; }
[NotAllowedBase64FileExtensions(true,new[] { ".png","jpeg" })]
public IFormFile? File { get; set; }