Validate that a field value does not contain "-"

Hi there,

I am trying to use the notContains validator on a field to make sure there is no - entered. However, if I set it up like this

myfield:
  type: text
  validate:
    notContains:
      '-'

it does not work. The same setup with a normal character works however. How can I validate that my field does not contain a -?

Thanks!

Don’t know, but maybe validate against a regex pattern instead.

Thanks pixelijn, how would I do that?

http://getkirby2.com.test/docs/guide/blueprints/fields#validating-fields

Oh, I just found out that I can write it like this:

validate:
  notContains: '-'

Strange that it works with normal characters even with the line break but only without a line break with the -. But okay, now I got it work and can avoid figuring out a fitting regex. :wink: Thanks anyways for the regex idea, pixelijn!