Is there possible ? If not can you help me to implement it ?
Add typescripts decorators to generated typescript. Also support for private class fields.
using System.ComponentModel.DataAnnotations;
using CommunityToolkit.Mvvm;
using CommunityToolkit.Mvvm.ComponentModel;
[ExportTsClass]
public partial class ProductDto : ObservableValidator
{
[ObservableProperty]
[Required (ErrorMessage="Price is required")]
[Range(1, 999, ErrorMessage="price must be in the range [1, 999].")]
private decimal _price;
[ObservableProperty]
private string[] _tags;
}
generated class
export class ProductDto extends ObservableValidator
{
@Required ("Price is required")
@Range(1, 999, "price must be in the range [1, 999].")
private _price: number;
private _tags: string[];
}
Only genarate c# attributes that inherits from ValidatorAttribute to typescript decorators. All others attributes will be ignored. ErrorMessage attribute property will be translated to msg typescript decorator parameter