MCPcopy Index your code
hub / github.com/microsoft/SandDance / validate

Method validate

packages/sanddance-specs/src/specBuilder.ts:74–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72 }
73
74 public validate() {
75 const { specContext } = this;
76 const { specCapabilities } = this.props;
77 const { roles } = specCapabilities;
78 const required = roles.filter(r => {
79 switch (typeof r.allowNone) {
80 case 'boolean':
81 return !r.allowNone;
82 case 'undefined':
83 return true;
84 case 'function':
85 return !r.allowNone(specContext);
86 }
87 });
88 const numeric = roles.filter(r => r.excludeCategoric);
89 const errors = required
90 .map(
91 r => {
92 if (specContext.specColumns[r.role]) {
93 return null;
94 } else {
95 return `Field ${r.role} is required.`;
96 }
97 },
98 )
99 .concat(
100 numeric.map(
101 r => {
102 if (specContext.specColumns[r.role] && !specContext.specColumns[r.role].quantitative) {
103 return `Field ${r.role} must be quantitative.`;
104 } else {
105 return null;
106 }
107 },
108 ),
109 )
110 .filter(Boolean);
111 return errors;
112 }
113
114 public build(): SpecResult {
115 const { globalSignals, specContext } = this;

Callers 1

buildFunction · 0.95

Calls 1

filterMethod · 0.45

Tested by

no test coverage detected