@@ -31,7 +31,7 @@ namespace cerberus {
3131 * @param schema The schema that this validator should be
3232 * validating against.
3333 */
34- explicit Validator (YAML::Node schema)
34+ explicit Validator (const YAML::Node& schema)
3535 : schema_(schema)
3636 , state(*this , YAML::Node())
3737 {
@@ -89,7 +89,7 @@ namespace cerberus {
8989 * @param name The name for the registered schema
9090 * @param schema The YAML::Node that represents the schema
9191 */
92- void registerSchema (const std::string& name, YAML::Node schema)
92+ void registerSchema (const std::string& name, const YAML::Node& schema)
9393 {
9494 schema_registry[name] = YAML::Clone (schema);
9595 }
@@ -143,7 +143,7 @@ namespace cerberus {
143143 * @param document The document to validate
144144 * @returns Whether or not the validation process was successful
145145 */
146- bool validate (YAML::Node document)
146+ bool validate (const YAML::Node& document)
147147 {
148148 return validate (document, schema_);
149149 }
@@ -156,7 +156,7 @@ namespace cerberus {
156156 * @param schema The schema to validate against
157157 * @returns Whether or not the validation process was successful
158158 */
159- bool validate (YAML::Node document, YAML::Node schema)
159+ bool validate (const YAML::Node& document, const YAML::Node& schema)
160160 {
161161 YAML::Node validated_schema;
162162 if (validate_schema)
@@ -186,7 +186,7 @@ namespace cerberus {
186186 * @param schema The schema to validate against
187187 * @returns Whether or not the validation process was successful
188188 */
189- bool validate (YAML::Node document, const std::string& schema)
189+ bool validate (const YAML::Node& document, const std::string& schema)
190190 {
191191 return validate (document, schema_registry[schema]);
192192 }
@@ -228,7 +228,7 @@ namespace cerberus {
228228 * @param validator the Validator instance
229229 * @param document The document to validate
230230 */
231- ValidationRuleInterface (Validator& validator, YAML::Node document)
231+ ValidationRuleInterface (Validator& validator, const YAML::Node& document)
232232 : validator(validator)
233233 {
234234 document_stack.reset (YAML::Clone (document));
@@ -271,7 +271,7 @@ namespace cerberus {
271271 RulePriority::LAST })
272272 {
273273 // Implement the require all policy of the validator
274- if ((priority == RulePriority::NORMALIZATION) && ( require_all) )
274+ if ((priority == RulePriority::NORMALIZATION) && require_all)
275275 schema[" required" ] = " true" ;
276276
277277 for (auto ruleval : schema)
@@ -299,7 +299,7 @@ namespace cerberus {
299299 *
300300 * @param schema Will go away in favor of the schema already being pushed on the stack
301301 */
302- bool validateDict (YAML::Node schema)
302+ bool validateDict (const YAML::Node& schema)
303303 {
304304 // Store the schema in validation state to have it accessible in rules
305305 schema_stack.push_back (schema);
@@ -309,7 +309,7 @@ namespace cerberus {
309309 for (auto fieldrules : schema)
310310 {
311311 pushCurrentField (fieldrules.first .as <std::string>());
312- auto rules = fieldrules.second ;
312+ const auto & rules = fieldrules.second ;
313313 document_stack.pushDictItem (getCurrentField ());
314314 std::string oldCurrentField = getCurrentField ();
315315 validateItem (rules);
@@ -323,7 +323,7 @@ namespace cerberus {
323323 popCurrentField ();
324324 }
325325
326- if (( purge_unknown) && (found.size () != getDocument ().size ()))
326+ if (purge_unknown && (found.size () != getDocument ().size ()))
327327 {
328328 YAML::Node newnode;
329329 for (auto item : getDocument ())
@@ -408,7 +408,7 @@ namespace cerberus {
408408 YAML::Node getSchema (std::size_t level = 0 , bool is_full_schema = false )
409409 {
410410 YAML::Node schema = schema_stack.get (level);
411- if (( is_full_schema) && (schema.IsScalar ()))
411+ if (is_full_schema && (schema.IsScalar ()))
412412 return validator.schema_registry [schema.as <std::string>()];
413413 else
414414 return schema;
@@ -508,7 +508,7 @@ namespace cerberus {
508508 }
509509
510510 // ! Reset the internal state to a new root document
511- void reset (YAML::Node document)
511+ void reset (const YAML::Node& document)
512512 {
513513 errors.clear ();
514514 document_stack.reset (YAML::Clone (document));
@@ -569,8 +569,8 @@ namespace cerberus {
569569 ValidationRuleInterface state;
570570
571571 std::map<std::pair<RulePriority, std::string>, std::function<void (ValidationRuleInterface&)>> rulemapping;
572- std::map<std::string, std::shared_ptr<TypeItemBase>> typesmapping;
573- std::map<std::string, YAML::Node> schema_registry;
572+ std::map<std::string, std::shared_ptr<TypeItemBase>, std::less<> > typesmapping;
573+ std::map<std::string, YAML::Node, std::less<> > schema_registry;
574574
575575 // The schema that is used to validate user provided schemas.
576576 // This is update with snippets as rules are registered
0 commit comments