Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

field transform #2

Open
EdwardZZZ opened this issue May 17, 2021 · 3 comments
Open

field transform #2

EdwardZZZ opened this issue May 17, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@EdwardZZZ
Copy link
Member

like this.

class User {
    @ToNumber()
    age: number;
}

const user = new User();
user.age = '18';

console.log(user.name); // >> 18;
@EdwardZZZ EdwardZZZ added the enhancement New feature or request label May 17, 2021
@dazjean
Copy link
Member

dazjean commented May 19, 2021

对于数字和布尔类型非常有用,除了这两种场景之外,是否还有必要增加别的呢?或者更加业务点的装饰器,比如对手机号,身份证等敏感信息进行脱敏?

@EdwardZZZ
Copy link
Member Author

对于数字和布尔类型非常有用,除了这两种场景之外,是否还有必要增加别的呢?或者更加业务点的装饰器,比如对手机号,身份证等敏感信息进行脱敏?

类型转换只是转换的一部分,如果敲定的话会作为默认功能提供,transform 希望能做到更多的转换,提供一种能力供扩展

@EdwardZZZ
Copy link
Member Author

需要考虑的事情:
1、转换的扩展形式,是基于 rule,还是新的方式
2、转换的时机,如果和校验同时使用,是先校验,还是先转换?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants