@ttoss/forms 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -1,7 +1,5 @@
1
- import './i18n';
2
-
3
1
  export { yupResolver } from '@hookform/resolvers/yup';
4
- export * as yup from 'yup';
2
+ export { yup } from './yup/yup';
5
3
 
6
4
  export { Form } from './Form';
7
5
  export { FormField } from './FormField';
@@ -0,0 +1,12 @@
1
+ import * as yup from 'yup';
2
+ import { isCnpjValid } from '../Brazil/FormFieldCNPJ';
3
+ /**
4
+ * Need this import to extend yup types on build time.
5
+ */
6
+ import './typings.d';
7
+
8
+ yup.addMethod(yup.string, 'cnpj', function () {
9
+ return this.test('valid-cnpj', 'Invalid CNPJ', (value) => {
10
+ return isCnpjValid(value);
11
+ });
12
+ });
@@ -0,0 +1,14 @@
1
+ import { AnyObject, Flags, Maybe, Schema } from 'yup';
2
+
3
+ declare module 'yup' {
4
+ interface StringSchema<
5
+ TType extends Maybe<string> = string | undefined,
6
+ TContext extends AnyObject = AnyObject,
7
+ TDefault = undefined,
8
+ TFlags extends Flags = '',
9
+ > extends Schema<TType, TContext, TDefault, TFlags> {
10
+ cnpj(): this;
11
+ }
12
+ }
13
+
14
+ export {};
package/src/yup/yup.ts ADDED
@@ -0,0 +1,4 @@
1
+ import './i18n';
2
+ import './schema';
3
+
4
+ export * as yup from 'yup';
File without changes