-
Notifications
You must be signed in to change notification settings - Fork 140
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
feat(cdk:forms): add use form control and vaalidators #121
Conversation
Codecov Report
@@ Coverage Diff @@
## main #121 +/- ##
==========================================
+ Coverage 95.52% 96.19% +0.66%
==========================================
Files 45 49 +4
Lines 604 762 +158
Branches 104 141 +37
==========================================
+ Hits 577 733 +156
- Misses 10 11 +1
- Partials 17 18 +1
Continue to review full report at Codecov.
|
packages/cdk/forms/validators.ts
Outdated
|
||
static minLength(minLength: number): ValidatorFn { | ||
return (value: any): { minLength: ValidationError } | null => { | ||
if (isEmpty(value) || !hasLength(value) || value.length >= minLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
关于长度的判断,是否要改成真实字符个数 与 字节长度两种形式
- 比如 emoji 按现在算的话,会算成长度 2 的,但实际只是一个字符啊
- 如果要算 2 ,那么是否要提供另外一个按字节计算的?比如utf-8可能是 2 3 4 个字节
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我认为我们 Cdk 内置的这些校验函数,应该尽可能的简单。
如果用户有特殊的场景,自己实现一个相关的验证函数也是很简单的。
packages/cdk/forms/validators.ts
Outdated
if (pattern.charAt(0) !== '^') regexStr += '^' | ||
regexStr += pattern | ||
if (pattern.charAt(pattern.length - 1) !== '$') regexStr += '$' | ||
regex = new RegExp(regexStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里看下要不要用第三方的正则处理库,来专门处理下转码,要不会存在以下的问题:
比如我传入'\\w'
,我的本意是js本身对字符串处理的原因,\
这个字符是需要转码的,需要\\
这样的形式才可以表达出\
这一个字符,我上面的意思是想匹配 \
w
这两个字符的。但按现在实现方式,regex
实际是/\w/,匹配的是单词,跟我的意图不一致。这里用户必须自己传成 \\\\w
才是对的,但这样就恶心了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上条。
* test(cdk:forms): add test fix #115
* main: docs(cdk:forms): add validators docs (IDuxFE#128) feat(cdk:forms): add useFormControl and Validtors (IDuxFE#121) fix(comp: image): export type to fix vite error (IDuxFE#127) docs: contribution (IDuxFE#125) refactor(comp:all): export type declaration from current component (IDuxFE#124) style(scripts): add brace style eslint rule (IDuxFE#123) refactor: script gen types template (IDuxFE#119) refactor: script gen type structure (IDuxFE#118) fix: add engines to package.json (IDuxFE#117)
fix IDuxFE#77 build: upgrade vite (IDuxFE#102) refactor(comp:all): updalte all components ts definition (IDuxFE#103) docs: update all components index.zh.md (IDuxFE#105) * docs: update gen script fix(comp: divider): dynamic slot (IDuxFE#104) fix IDuxFE#76 feat(comp: spin): add spin component (IDuxFE#101) fix IDuxFE#72 refactor(comp:core): useGlobalConfig (IDuxFE#107) fix: vite traverse filename config (IDuxFE#106) docs: update spin component demo (IDuxFE#109) fix(comp: divider): slots rerender (IDuxFE#110) refactor(comp:i18n): update useI18n to useLocale (IDuxFE#111) feat(comp: space): add component space (IDuxFE#97) fix IDuxFE#63 fix(comp:all): solot dynamic load (IDuxFE#114) fix: add engines to package.json (IDuxFE#117) yarn start error because of the low version of Node.js fix IDuxFE#116 refactor: script gen type structure (IDuxFE#118) refactor: script gen types template (IDuxFE#119) * Update the template to make it more simpler. style(scripts): add brace style eslint rule (IDuxFE#123) fix IDuxFE#122 refactor(comp:all): export type declaration from current component (IDuxFE#124) docs: contribution (IDuxFE#125) update contributing.zh and add contributing.en fix(comp: image): export type to fix vite error (IDuxFE#127) feat(cdk:forms): add useFormControl and Validtors (IDuxFE#121) * test(cdk:forms): add test fix IDuxFE#115 docs(cdk:forms): add validators docs (IDuxFE#128) re IDuxFE#115 docs: modify components' docs' type (IDuxFE#131) feat(comp: empty): add component empty (IDuxFE#132) * feat(comp:empty): update and add test fix IDuxFE#54 feat(cdk:utils): add hasOwnProperty function (IDuxFE#137) fix(comp: badge): overflowCount not work (IDuxFE#135) fix IDuxFE#134 test(comp:badge,icon): fix warning (IDuxFE#140) feat(comp: result): add result component (IDuxFE#136) fix IDuxFE#112 feat(cdk:forms): add formGroup and formArray (IDuxFE#139) * feat(cdk:forms): add test re IDuxFE#115 feat(cdk:forms): add utils (IDuxFE#141) re IDuxFE#115 refactor(cdk:forms): `modelRef` renamed to `valueRef` (IDuxFE#142) re IDuxFE#115 feat(cdk:forms): add watchValue and watchStatus (IDuxFE#143) re IDuxFE#115 refactor(cdk:forms): add dirty status and marks `valueRef` to readonly (IDuxFE#144) re IDuxFE#115 feat(cdk:forms): setValue support configuration options (IDuxFE#146) re IDuxFE#115 feat: add global types (IDuxFE#150) docs(cdk:forms): add docs and demo (IDuxFE#149) fix IDuxFE#115 refactor(cdk:forms): update typescript defintions (IDuxFE#151) * docs(cdk:forms): update docs feat(cdk: subject): add subject (IDuxFE#155) fix IDuxFE#154 feat(comp: typography): add directive typography (IDuxFE#148) * docs(comp: typography): modify docs * feat(comp: typography): add type check * feat(comp: typography): style * test(comp: typography): add test fix IDuxFE#130 feature(comp:card): 1.修改dom结构 2.补全css样式 3.重跑单测 feat(comp:card): 1.解决合并冲突 feat(comp:card): add card component
fix #115
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
Other information