@sanity/validation 2.22.4-reference-updates.58 → 2.22.6-field-groups.141

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Rule.d.ts","sourceRoot":"","sources":["../../src/Rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAUV,MAAM,eAAe,CAAA;AA0DtB,QAAA,MAAM,IAAI,EAAE,SA2VX,CAAA;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"Rule.d.ts","sourceRoot":"","sources":["../../src/Rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAUV,MAAM,eAAe,CAAA;AA0DtB,QAAA,MAAM,IAAI,EAAE,SAkWX,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ValidationMarker, ValidationError, ValidationContext } from '@sanity/types';
2
2
  declare type ValidationErrorLike = Pick<ValidationError, 'message'> & Partial<ValidationError>;
3
3
  export declare function isNonNullable<T>(t: T): t is NonNullable<T>;
4
- export default function convertToValidationMarker(validatorResult: true | true[] | string | string[] | ValidationError | ValidationError[] | ValidationErrorLike | ValidationErrorLike[], level: 'error' | 'warning' | undefined, context: ValidationContext): ValidationMarker[];
4
+ export default function convertToValidationMarker(validatorResult: true | true[] | string | string[] | ValidationError | ValidationError[] | ValidationErrorLike | ValidationErrorLike[], level: 'error' | 'warning' | 'info' | undefined, context: ValidationContext): ValidationMarker[];
5
5
  export {};
6
6
  //# sourceMappingURL=convertToValidationMarker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertToValidationMarker.d.ts","sourceRoot":"","sources":["../../../src/util/convertToValidationMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAIlF,aAAK,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAEtF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAE1D;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,eAAe,EACX,IAAI,GACJ,IAAI,EAAE,GACN,MAAM,GACN,MAAM,EAAE,GACR,eAAe,GACf,eAAe,EAAE,GACjB,mBAAmB,GACnB,mBAAmB,EAAE,EACzB,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,EACtC,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,EAAE,CA2DpB"}
1
+ {"version":3,"file":"convertToValidationMarker.d.ts","sourceRoot":"","sources":["../../../src/util/convertToValidationMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAIlF,aAAK,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAEtF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAE1D;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,eAAe,EACX,IAAI,GACJ,IAAI,EAAE,GACN,MAAM,GACN,MAAM,EAAE,GACR,eAAe,GACf,eAAe,EAAE,GACjB,mBAAmB,GACnB,mBAAmB,EAAE,EACzB,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EAC/C,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,EAAE,CA2DpB"}
package/lib/Rule.js CHANGED
@@ -120,6 +120,13 @@ var Rule = (_temp = _class = class Rule {
120
120
  return rule;
121
121
  }
122
122
 
123
+ info(message) {
124
+ var rule = this.clone();
125
+ rule._level = 'info';
126
+ rule._message = message || undefined;
127
+ return rule;
128
+ }
129
+
123
130
  reset() {
124
131
  this._type = this._type || undefined;
125
132
  this._rules = (this._rules || []).filter(rule => rule.flag === 'type');
@@ -44,7 +44,7 @@ var objectValidators = _objectSpread(_objectSpread({}, _genericValidator.default
44
44
  }
45
45
 
46
46
  if (!(0, _types.isReference)(value)) {
47
- return message || 'Must be a reference to a document';
47
+ return message || true;
48
48
  }
49
49
 
50
50
  var type = context.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/validation",
3
- "version": "2.22.4-reference-updates.58+9fe96fbe86",
3
+ "version": "2.22.6-field-groups.141+b498d782c",
4
4
  "description": "Validation and warning infrastructure for Sanity projects",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./dist/dts",
@@ -32,8 +32,8 @@
32
32
  "directory": "packages/@sanity/validation"
33
33
  },
34
34
  "devDependencies": {
35
- "@sanity/client": "2.22.4-reference-updates.58+9fe96fbe86",
36
- "@sanity/schema": "2.22.4-reference-updates.58+9fe96fbe86"
35
+ "@sanity/client": "2.22.6-field-groups.141+b498d782c",
36
+ "@sanity/schema": "2.22.6-field-groups.141+b498d782c"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@sanity/client": "^2.0.0"
@@ -44,9 +44,9 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "@sanity/types": "2.22.4-reference-updates.58+9fe96fbe86",
47
+ "@sanity/types": "2.22.6-field-groups.141+b498d782c",
48
48
  "date-fns": "^2.16.1",
49
49
  "lodash": "^4.17.15"
50
50
  },
51
- "gitHead": "9fe96fbe861072094c4aef3bd9306f6279197019"
51
+ "gitHead": "b498d782c2296fc8169cfba7a125b104624024c4"
52
52
  }
package/src/Rule.ts CHANGED
@@ -83,7 +83,7 @@ const Rule: RuleClass = class Rule implements IRule {
83
83
  })
84
84
 
85
85
  _type: RuleTypeConstraint | undefined = undefined
86
- _level: 'error' | 'warning' | undefined = undefined
86
+ _level: 'error' | 'warning' | 'info' | undefined = undefined
87
87
  _required: 'required' | 'optional' | undefined = undefined
88
88
  _typeDef: SchemaType | undefined = undefined
89
89
  _message: string | undefined = undefined
@@ -118,6 +118,13 @@ const Rule: RuleClass = class Rule implements IRule {
118
118
  return rule
119
119
  }
120
120
 
121
+ info(message?: string): Rule {
122
+ const rule = this.clone()
123
+ rule._level = 'info'
124
+ rule._message = message || undefined
125
+ return rule
126
+ }
127
+
121
128
  reset(): this {
122
129
  this._type = this._type || undefined
123
130
  this._rules = (this._rules || []).filter((rule) => rule.flag === 'type')
@@ -18,7 +18,7 @@ export default function convertToValidationMarker(
18
18
  | ValidationError[]
19
19
  | ValidationErrorLike
20
20
  | ValidationErrorLike[],
21
- level: 'error' | 'warning' | undefined,
21
+ level: 'error' | 'warning' | 'info' | undefined,
22
22
  context: ValidationContext
23
23
  ): ValidationMarker[] {
24
24
  if (validatorResult === true) return []
@@ -26,7 +26,7 @@ const objectValidators: Validators = {
26
26
  }
27
27
 
28
28
  if (!isReference(value)) {
29
- return message || 'Must be a reference to a document'
29
+ return message || true
30
30
  }
31
31
 
32
32
  const {type, getDocumentExists} = context