@coxy/react-validator 3.0.0 → 4.0.0

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.
@@ -28,3 +28,13 @@ it('check normal add and remove fields', () => {
28
28
  newFieldSearchPassword = validator.getField('for-remove')
29
29
  expect(newFieldSearchPassword === null).toBe(true)
30
30
  })
31
+
32
+ it('removeField does nothing when field is not registered', () => {
33
+ const validator = new Validator()
34
+ // create a field-like object that validator doesn't know about
35
+ // import Field from the module is possible, but we can emulate shape using any
36
+ // Should not throw and should not alter state
37
+ // @ts-expect-error.
38
+ expect(() => validator.removeField({})).not.toThrow()
39
+ expect(validator.getField('unknown')).toBe(null)
40
+ })
package/src/validator.ts CHANGED
@@ -3,9 +3,9 @@ import type { FieldParams, Validity } from './types'
3
3
  import type { Value } from './validator-field'
4
4
 
5
5
  export class Field {
6
- private rules: ValidatorRules
7
- private required: boolean
8
- private value: Value
6
+ protected rules: ValidatorRules
7
+ protected required: boolean
8
+ protected value: Value
9
9
  public id: string | number
10
10
 
11
11
  constructor({ rules, required, value, id }: FieldParams) {
package/src/jest.d.ts DELETED
@@ -1,2 +0,0 @@
1
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
2
- declare let shallow: any