---
# System prepended metadata

title: Untitled

---

Template Replace Schema Error Message


`schema.yml`
```yaml
#@data/values-schema
---
service:
  enabled: true
```
`datavalues.yml`
```yaml
#@ load("@ytt:template", "template")
#@ load("funcs.lib.yml", "service")
#@data/values
---
_: #@ template.replace(service())
```
`funcs.lib.yaml` (1)
```yaml
#@ def service():
#@   return {'service': {'enabled': 8}}
#@ end
```
`funcs.lib.yaml` (2)
```yaml
#@ def service():
service: 
  enabled: 8
#@ end
```

Error (1)
```
Overlaying data values (in following order: defaults.yml): 
One or more data values were invalid
====================================

defaults.yml:
     |
  10 | _: #@ template.replace(service())
     |

     = found: integer
     = expected: boolean (by schema.yml:8)
```

Error (2) - Good
```
Overlaying data values (in following order: defaults.yml): 
One or more data values were invalid
====================================

config-4.lib.yml:
    |
  3 |   enabled: 8
    |

    = found: integer
    = expected: boolean (by schema.yml:8)
```
Desired Error
```
One or more data values were invalid
====================================

funcs.lib.yml:
     |
   2 | enabled: 8
     |

     = found: integer
     = expected: boolean (by schema.yml:4)
```
---
`schema.yml`
```yaml
#@ load("@ytt:template", "template")
#@ load("@ytt:library", "library")
--- #@ template.replace(library.get("lib").with_data_values({'foo':'bar', 'cat': 'cow'}).eval()))
```
`libSchema.yaml`
```yaml
#@data/values-schema
---
foo: 3
cat: meow
```

Error
```
- library.eval: Evaluating library 'libby': Overlaying data values (in following order: additional data values): 
    in <toplevel>
      config.yml:3 | --- #@ template.replace(library.get("libby").with_data_values({'foo':'bar', 'cat': 'cow'}).eval())

    reason:
     One or more data values were invalid
     ====================================
     
     :
         |
       ? | 
         |
     
         = found: string
         = expected: integer (by _ytt_lib/libby/schema.yml:3)
```
Desired Error:
```
- library.eval: Evaluating library 'lib': Overlaying data values (in following order: additional data values): 
    in <toplevel>
      config.yml:4 | --- #@ template.replace(library.get("lib").with_data_values({'foo':'bar'}).eval())

    reason:
     One or more data values were invalid
     ====================================
     
     config.yml:
         |
       4 | foo: bar
         |
     
         = found: string
         = expected: integer (by _ytt_lib/lib/schema.yml:4)
```
---

`config.yml`
```yaml
#@ load("@ytt:template", "template")
#@ load("funcs.lib.yml", "service")
#@ load("@ytt:library", "library")
--- #@ template.replace(library.get("libby").with_data_values(service()).eval())
```

`_ytt_lib/libby/schema.yml`
```yaml
#@data/values-schema
---
foo: 3
cat: meow
```

`funcs.lib.yml` (1)
```yaml
#@ def service():
#@   return {'foo': 'enabled', 'cat': 'cow'}
#@ end
```
`funcs.lib.yml` (2)
```
#@ def service():
foo: enabled
cat: cow
#@ end
```

Error (1)
```
- library.eval: Evaluating library 'libby': Overlaying data values (in following order: additional data values): 
    in <toplevel>
      config.yml:4 | --- #@ template.replace(library.get("libby").with_data_values(service()).eval())

    reason:
     One or more data values were invalid
     ====================================
     
     :
         |
       ? | 
         |
     
         = found: string
         = expected: integer (by _ytt_lib/libby/schema.yml:3)
```

Error (2) - Good
```
 library.eval: Evaluating library 'libby': Overlaying data values (in following order: additional data values): 
    in <toplevel>
      config.yml:4 | --- #@ template.replace(library.get("libby").with_data_values(service()).eval())

    reason:
     One or more data values were invalid
     ====================================
     
     funcs.lib.yml:
         |
       2 | foo: enabled
         |
     
         = found: string
         = expected: integer (by _ytt_lib/libby/schema.yml:3)
```
Desired Error
```
- library.eval: Evaluating library 'lib': Overlaying data values (in following order: additional data values): 
    in <toplevel>
      config.yml:4 | --- #@ template.replace(library.get("lib").with_data_values(service()).eval())

    reason:
    One or more data values were invalid
    ====================================

    funcs.lib.yml:
        |
      2 | foo: bar
        |

        = found: string
        = expected: integer (by _ytt_lib/libby/schema.yml:3)
```