Source

hydra / apps / externals / validate_doc_update.py

Full commit
def validate(newdoc, olddoc, userctx, secobj):
    user = require('lib/userctx')['init'](userctx, secobj)
    if user.is_admin() or user.is_db_admin():
        # You're admin, nothing will stop you, but you in respond for all there!
        return

    root = require('lib/doc/field')['init'](newdoc, olddoc)

    with root('/.meta') as field:
        field.required()
        field.is_object()

    if 'externals' in newdoc['.meta']:
        with root('/.meta/externals') as externals:
            externals.is_object()

            for system in externals:
                system.is_object()

                with system('/id') as field:
                    field.required()
                    field.is_string()

                with system('/host') as field:
                    field.required()
                    field.is_string()